PDA

View Full Version : [CLOSED] Dynamic Formpanel Setvalues



tpayn
Oct 01, 2012, 7:04 PM
Hi,

We have a requirement where dynamic formpanels will be build by a handler or service and in my mock up testing i found that the setvalues function is not setting the form values. Could you kindly point me in the correct direction?

default.aspx:

<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<ext:Viewport runat="server" Layout="border">
<Items>
<ext:Panel runat="server" Layout="Fit" Title="Center" Region="Center">
<Loader DirectMethod="#{DirectMethods}.LoadPanel" runat="server" Mode="Component">
<LoadMask ShowMask="true" />
</Loader>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>

default.aspx.cs

public partial class Default : System.Web.UI.Page
{

[DirectMethod]
public static string LoadPanel()
{
return ComponentLoader.ToConfig(GetFormPanel());
}

private static AbstractComponent GetFormPanel()
{
FormPanel form = new FormPanel() { ID = "FormPanel1", Title = "Tester" };
form.Items.Add(new TextField() { FieldLabel = "test label", ID = "testname", Name = "testname", Width = Unit.Pixel(250) });
form.SetValues(new { testname = "testing" });
return form;
}
}

Daniil
Oct 02, 2012, 5:46 AM
Hi @tpayn,

Welcome to Ext.NET!

Well, the SetValues method generates a script to be executed on client. This method and other similar ones require that a control must be added to the page controls.

Though, even if it would be added to the page controls, it doesn't make sense, because a Loader with Component Mode expects just a component config.

So, please initialize the fields using its Text or Value properties. In the case with TextField, please use the Text property.

tpayn
Oct 02, 2012, 7:43 AM
Hi Daniil,

Thank you for the feedback. We are very green on the Ext.Net toolkit and we will have to rethink our approach a bit.

Regards
Terence

Daniil
Oct 02, 2012, 9:21 AM
Hi Terence,

Please ask if you will be in trouble. We are here to help.