c# - Add Event Handler to User Control from custom object -
I have created a user control in which there will be a table of linkbutton (and other information). I create table rows in another custom object and return a TableRowCollection with some link buttons in these table rows.
In the rear code for user control I have created an event handler for the button click, these passwords pass the user control in the call call to make the buttons lines (using "this") And then try to add event handler to "click" in the link button. For some reason, the event handler does not fire back on a post due to this button. What can I do to make this incident a fire?
Here is the code where I create a button and add event handlers:
link button button = new LinkButton (); button. Text = movie title; button. Click + = new event here. Dragler (Control LinkedClick); button. CommandArgument = result.localid.toString (); Cell1.Controls.Add (button);
Where "control" user controls have been passed as a parameter and the "Link_Click" event handler is.
Thanks in advance!
First of all, if the event handler is already under the control of the user, then any reference to it You do not need to pass in the way. You can easily use any property or method inside the event handler.
Events depend on the wire-up for correct control over the control ID. If you do not create your linkbutton at all postbacks at all times and make sure that they have the same ID that was done earlier, then your event handler will not fire, because the ASP.NET pipeline will not be able to see that How this control thinks the right button in the tree.
In addition, if you are restricting your user control to your data source on every postback, then it may lose the events for some control,
To check that you are reproducing your control every time, and not every time your user is binding again.
Comments
Post a Comment