Oct 19, 2017, 9:13 AM
DirectEvent in CodeBehind not working in a Window
Hello,
I have a window which contains 2 numberfields, one is created in the aspx file and the other one is created dynamically in codebehind when the whindow is shown. Both of them are identical, but the DirectEvent created on the dynamically one is not working.
I have createa test to show you what is happening:
Test.Aspx
Thank you and hope you can help.
Pascu
I have a window which contains 2 numberfields, one is created in the aspx file and the other one is created dynamically in codebehind when the whindow is shown. Both of them are identical, but the DirectEvent created on the dynamically one is not working.
I have createa test to show you what is happening:
Test.Aspx
<body>
<form id="formGeneral" runat="server">
<ext:ResourceManager runat="server" />
<ext:Viewport ID="Mainvp" runat="server" Title="" Icon="Application"
Border="false" Collapsible="false"
Plain="true" Layout="columnlayout" AutoScroll="true">
<Items>
<ext:Button
MinWidth="10"
text="open window"
ToggleGroup=""
runat="server">
<DirectEvents>
<Click OnEvent="ShowWindow"></Click>
</DirectEvents>
</ext:Button>
<ext:Window
ID="WindowDetalle"
runat="server"
BodyStyle="background-color: #fff;"
Hidden="true"
ExpandOnShow="false"
AutoScroll="true"
Maximizable="false"
AnchorHorizontal="true"
AnchorVertical="true"
Width="900"
Modal="true"
frame="false"
Closable="false"
AutoRender="true"
Draggable="false"
layout="ColumnLayout"
Resizable="false"
Y="10">
<Items>
<ext:Panel ID="Panel38" runat="Server" ColumnWidth="1" layout="columnlayout" autoscroll="true" Frame="false" MarginSpec="2 0 0 0">
<Items>
<ext:TextField ID="texto" runat="server" Text="3XL" readonly="true" ColumnWidth ="0.3" FieldStyle="text-align: center;" MarginSpec="0 0 0 0"/>
<ext:NumberField ID="NumberField26" runat="server" ColumnWidth =" 0.5" MarginSpec="0 0 0 2" MinValue="0" Number="0">
<DirectEvents>
<change OnEvent ="ActualizaTotal" />
</DirectEvents>
</ext:NumberField>
<ext:Label runat="server" ColumnWidth =" 0.2" Icon="Bulletgreen" MarginSpec="8 0 0 2">
<ToolTips>
<ext:ToolTip runat="server" Html="Disponible"></ext:ToolTip>
</ToolTips>
</ext:Label>
</Items>
</ext:Panel>
<ext:Panel ID="panelcodebehind" runat="Server" ColumnWidth="1" layout="columnlayout" autoscroll="true" Frame="false" MarginSpec="2 0 0 0">
</ext:Panel>
</Items>
</ext:Window>
</Items>
</ext:Viewport>
</form>
</body>
Test.apsx.cspublic partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void ShowWindow(object sender, EventArgs e)
{
Ext.Net.Panel paneltalla = new Ext.Net.Panel();
paneltalla.ID = "panel";
paneltalla.ColumnWidth = 1;
paneltalla.Layout = "columnlayout";
paneltalla.MarginSpec = "2 0 0 0";
paneltalla.AddTo(panelcodebehind);
Ext.Net.TextField NTalla = new Ext.Net.TextField();
NTalla.ID = "ntalla";
NTalla.Text = "test";
NTalla.ColumnWidth = 0.3;
NTalla.ReadOnly = true;
NTalla.SetFieldStyle("text-align: center");
NTalla.MarginSpec = "0 0 0 0";
NTalla.AddTo(paneltalla);
Ext.Net.NumberField CantTalla = new Ext.Net.NumberField();
CantTalla.ID = "ncant";
CantTalla.ColumnWidth = 0.5;
CantTalla.MarginSpec = "0 0 0 2";
CantTalla.MinValue = 0;
CantTalla.Number = 0;
CantTalla.AddTo(paneltalla);
CantTalla.DirectEvents.Change.Event += new ComponentDirectEvent.DirectEventHandler(this.ActualizaTotal2);
Ext.Net.Label disponible = new Ext.Net.Label();
disponible.ColumnWidth = 0.2;
disponible.Icon = Ext.Net.Icon.BulletGreen;
disponible.MarginSpec = "8 0 0 2";
disponible.AddTo(paneltalla);
WindowDetalle.Hidden = false;
WindowDetalle.Show();
}
public void ActualizaTotal(object sender, EventArgs e)
{
texto.Text = "3";
}
public void ActualizaTotal2(object sender, EventArgs e)
{
texto.Text = "5";
}
}
(line 35 not working)Thank you and hope you can help.
Pascu
Last edited by Pascu; Oct 19, 2017 at 9:15 AM.