I have an ASCX control (called A) that is used by an ASPX page . The aspx page has an event (called E) listener and all the appropriated functions to handle this event coming from another ASCX page (called B).
Once the event E has been completed, a property of the control A is set and I have enough information to "render" the control A which is made by a set of dynamic controls. My problem is that I do not know how to add event handlers to these dynamic controls. I tried the following code (in control A):
override protected void OnPreRender(EventArgs e)
for(int i=0; i<this.FindControl("my3345").Controls.Count; i++)
if(this.FindControl("my3345").Controls[i] is LinkButton)
LinkButton lb = (LinkButton)this.FindControl("my3345").Controls[i];
lb.Command+= new System.Web.UI.WebControls.CommandEventHandler(this.linkbuttonclick);
The main problem is that the requested property (myProperty) is not set when the Page_Load of this control A is called because all "postback" events are treated afterwards. So when can I generate these controls and give they their respective CommandEventHandler ?
I know the question is a bit tricky because out of context... But please help!!!