Developer forum

Forum » Development » DW8, Custom Module and _Edit UserControl

DW8, Custom Module and _Edit UserControl

Rene Poulsen
Reply
 Hi,

I've got 2 problems saving the modulesettings on my paragraph edit .ascx usercontrol for a custom module I'm creating.

I've created a simple example that shows my problem.



Problem 1:
In my HellowWorld_Edit.ascx I've got the following module settings and controls:
<dw:modulesettings id="ModuleSettings1" runat="server" modulesystemname="HelloWorld" value="myText,myTemplate"></dw:modulesettings>
<input id="myText" class="std" runat="server" type="text" />
<dw:filemanager id="myTemplate" runat="Server" folder="/Templates/HelloWorld/" name="myTemplate" />

In the Page_Load of HelloWorld_Edit.ascc I've got the following:
Dynamicweb.Properties p = default(Dynamicweb.Properties):
Dynamicweb.Properties p = default(Dynamicweb.Properties);
p = Dynamicweb.Properties.LoadProperties();
p.SetDefaultValue("myText", "Hello default text");
p.SetDefaultValue("myTemplate", "template.html");

myText.Value = p.Values["myText"].ToString();
myTemplate.Value = p.Values["myTemplate"].ToString();

When I create a new paragraph and attach the module I write something in the input field and choose a different template then "template.html".

The text I write in the input field isn't saved but the the template i choose is successfully saved.

When I take a look into the database I see the following in the "ParagraphModuleSettings" column for the paragraph:
<?xml version="1.0" encoding="utf-8"?><Settings><myText></myText><myTemplate>template_v2.html</myTemplate><myTemplate_path>/Files/Templates/HelloWorld/template_v2.html</myTemplate_path></Settings>

What am I doing wrong?


Problem 2:
Pretty simple: On my HelloWorld_Edit.ascx I wan't to create an asp:DropDown with some values from a database I created for my module. The problem is the same as above - the value isn't saved even though I specify the ID of the control in the ModuleSettings on my _Edit usercontrol.

Can't i use ASP.NET controls for ModuelSettings?

Any suggestions :-)



Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Hi Rene,

I reported the same problem back in March. It was bugged as TFS-7607. I think the plan back then was to only fix this for the upcoming Dynamicweb 8.1 release, so this could very well be a bug in your 8.0 installation.

Maybe DW can merge this back into the 8.0 release, or you could use an ASPX page instead of a User Control to work around these issues.

Cheers,

Imar

 
Morten Bengtson
Reply
Problem 1: Try to add a name attribute to your text field.
<input id="myText" name="myText" class="std" runat="server" type="text" />
Problem 2: Try using a plain select with runat=server - does it have to be a DropDownList control?
<select id="mySelect" name="mySelect" runat="server">        
</select>

/Morten

 
Rene Poulsen
Reply
Hi Imar and Morten,

Thanks for your replies. Maybe I should just go back to using an .aspx page instead. I've tried adding name attributes (like you suggested, Morten), but it still doesn't work.

I'll try using a <select> instead of the asp:dropdown. I guess that should do it :-)


// René
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
If you use a server side <select>, I think you'll run into the same problem. In DW 8 / .NET 4, the client name of controls that run at the server is changed, and Dynamicweb is no longer able to find them in the post variables. Check the HTML for the _Edit page / user control and you'll see they have different name attributes. The fix in 8.1 looks at control name by ignoring the part that .NET has added to the client name.

Cheers,

Imar

 
Rene Poulsen
Reply
I'm working on it right now. I switched back to using an .aspx page and a <select> with runat="server" actually works great. I don't use the name attributes - just IDs.
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Yes, the problem does not exist in ASPX pages.
 

I don't use the name attributes - just IDs.
 

If they run at the server, .NET will give them a name (just check the HTML in the browser to see what I mean). It's the name that makes the item submit itself to the server where .NET and thus Dynamicweb can read its value and store it with the paragraph settings in the database.

Cheers,

Imar
 
Rene Poulsen
Reply
Off course, now I see what you mean :-)

Thanks again for your replies.

 

You must be logged in to post in the forum