Feb 08, 2011, 3:28 PM
Dynamically added button's direct event does not work
Please take a look at this:
This produces the following error:
Regards,
Darko
EDIT: The code actually works when the button is outside of the panel (directly on the aspx form).
But when the button is put inside the panel the error message appears.
Any ideas how to resolve this?
protected void Page_Load(object sender, EventArgs e)
{
Ext.Net.Button b1 = new Ext.Net.Button();
b1.Text = "test button";
b1.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_Event);
b1.AddTo(pnlCenter);
}
void Click_Event(object sender, DirectEventArgs e)
{
X.Msg.Alert("test message", "test");
}
The button is dynamically added to the pnlCenter which is on the aspx page.This produces the following error:
The control with ID 'id1a62f466f3ff47c985aad859f77faac0' not found
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The control with ID
'id1a62f466f3ff47c985aad859f77faac0' not found
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): The control with ID
'id1a62f466f3ff47c985aad859f77faac0' not found]
Ext.Net.ResourceManager.RaisePostBackEvent(String eventArgument) +1109
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+5563
How to dynamically add a control to the page and use its direct event handler?Regards,
Darko
EDIT: The code actually works when the button is outside of the panel (directly on the aspx form).
But when the button is put inside the panel the error message appears.
Any ideas how to resolve this?
Last edited by geoffrey.mcgill; Feb 08, 2011 at 5:53 PM.
Reason: please use [CODE] tags