PDA

View Full Version : [CLOSED] Dynamic Control + EventTarget and EventArgument



aisi_it_admin
Sep 02, 2012, 10:43 PM
Hello

this is kind of follow up of the http://forums.ext.net/showthread.php?20656-CLOSED-Field-outside-of-Form-panel-is-not-send-to-server
but as the problem is different I created new one.

In FF page works fine, in IE - when I add couple of dynamic control, then once click the button inside the dynamic control, I'm not able to attach another tab.
I think the reason is that that after clicking UserControl button, the two


<input type="hidden" name="__EVENTTARGET" value="">
<input type="hidden" name="__EVENTARGUMENT" value="">

hidden fields are added to the respective (child) form so when the parent form is submitted they are here twice

As a resul the server click event is not fired


btw, is there any way how to render <form> tag using ext controls?

page.aspx:




<script runat="server">
protected void Button1_Click(object sender, DirectEventArgs e)
{
if (string.IsNullOrEmpty(hid.Value as string))
{
hid.Value = "0";
}
else
{
hid.Value = (int.Parse(hid.Value as string) + 1).ToString();
}

UserControl uc1 = (UserControl)this.LoadControl("~/WindowsApp/UserControls/TextControll.ascx");
uc1.ID = "UC" + hid.Value;

var pnl = new Ext.Net.Panel()
{
ID = "dynamicPanel"+hid.Value,
Title = "Tab"+hid.Value,
CloseAction = CloseAction.Destroy,
Closable = true


};
pnl.ContentControls.Add(uc1);

pnl.Render("tabPanel", RenderMode.AddTo);



}

protected override void OnInit(EventArgs e)
{
var key = Request.Form.AllKeys.FirstOrDefault(item => item.Contains("hiddenField"));
if (string.IsNullOrEmpty(key) == false)
{
var countStr = Request[key];

if (countStr != null && countStr != "")
{
int count = int.Parse(countStr);


UserControl uc1 = (UserControl) this.LoadControl("~/WindowsApp/UserControls/TextControll.ascx");
uc1.ID = "UC" + count;

var pnl = new Ext.Net.Panel()
{
ID = "dynamicPanel" + count,

};
pnl.ContentControls.Add(uc1);
tabPanel.Controls.Add(pnl);

}

}
base.OnInit(e);
}

</script>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title>Update Controls and Content during a DirectEvent - Ext.NET Examples</title>


</head>
<body>
<script src="http://ala-test.allynintl.eu/ALAJavaScripts.ashx" type="text/javascript"></script>

<form runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" Namespace="" />

<ext:Hidden runat="server" ID="hid"/>
<ext:TabPanel
ID="tabPanel"
runat="server"
Title="Tab with dynamic controls"
Width="1000"
Height="800"
BodyPadding="5">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button runat="server" Text="Add" OnDirectClick="Button1_Click"></ext:Button>

</Items>
</ext:Toolbar>
</TopBar>
</ext:TabPanel>
</form>
</body>
</html>


testcontrols.ascx:


<form>
<ext:Hidden runat="server" ID="hiddenField" />
<ext:FormPanel runat="server">
<Items>
<ext:TextField runat="server" ID="txt1">
</ext:TextField>
<ext:Button runat="server" ID="btn" OnDirectClick="btnVoidTR_click" Text="Click me in IE and you will not be able to attach another tab">
</ext:Button>
</Items>
</ext:FormPanel>
</form>



The purpose of the excercice is:
- when directevent occure in the control, only the content of control is sent to server
- the direct events above the tabpanel still work ( I can get rid of the root form tag, but thenI need to use directevents

Thanks
Zdenek

Daniil
Sep 03, 2012, 9:13 AM
Hi,


There can be several forms in a single document, but the FORM element can't be nested.

It is a quote from this article.
http://www.w3.org/MarkUp/html3/forms.html

You can place all required field into a FormPanel and use its submit method.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Panel-method-submit