PDA

View Full Version : [CLOSED] Adding Click Event in code-behind



cwolcott
Jun 20, 2012, 5:31 PM
I have created my button in markup:



<ext:Button ID="PrevVersion" runat="server" Icon="ReverseBlue" />


Based on behind code I would like to add a Click Event and Parameters:



protected void SelectCfdbVersion(object sender, DirectEventArgs e)
{
...

PrevVersion.DirectEvents.Click.Event += SelectCfdbVersion;
PrevVersion.DirectEvents.Click.ExtraParams.Add(new Ext.Net.Parameter() {
Name = "Version",
Value = 25.ToString(),
Mode = ParameterMode.Value});

//Do I need to do something else with the PrevVersion button?
...
}


Is there something else I need to do? Because the Event is not firing.

Vladimir
Jun 20, 2012, 6:02 PM
First, DirectEvent cannot be added after component rendering.
Second, Dynamic server side event handler cannot be automatically maintained between requests (it is ASP.NET limitation). You have to attach event handler in Page_Init for each request

In your case, I can suggest to use combination of Listeners and DirectMethod (listener can be added dynamically via On/AddListener method and doesn't require recreating)