First off, I'd suggest that you move your control loading code to the Page Init or the Page PreRender method instead of the Page Load method, like this:
protected void Page_Init(object sender, EventArgs e) { controls_Exampletry myControl = (controls_Exampletry)Page.LoadControl("controls/Exampletry.ascx"); //Loading hte WebUserControl into am object called mycontrol myControl.ID = "MyControl1"; //Seting and ID for this object
HtmlTable StepsTable = new HtmlTable(); HtmlTableRow stepRow = new HtmlTableRow(); //This is a dynamic Row HtmlTableCell stepCell = new HtmlTableCell(); //This is a dynamic Cell
AjaxControlToolkit.CollapsiblePanelExtender cpe1 = new AjaxControlToolkit.CollapsiblePanelExtender(); //creating the Collapsible Panel from server side and give it an instance or object stepCell.Controls.Add(myControl);
stepCell.Controls.Add(cpe1);
cpe1.ID = "CollapsiblePanelExtender"; // giving an ID to the Collapsible Panel cpe1.TargetControlID = myControl.StepPanel.ID; //If the above line gives a problem, then try saying stepCell.FindControl(myControl.ID).ID
stepRow.Cells.Add(stepCell); StepsTable.Rows.Add(stepRow); //I have a table with ID=StepsTable that will received this adding of the row }
Lastly, in your case there are many complications like dynamically adding extenders (not just controls), dynamically adding user controls, trying to ask the extender to access a control inside the user control and many other things. So, I'm not sure whether the above code would still start working from the word go. So, you can keep posting your responses here, if things don't work.
tejpalthatte
Member
692 Points
126 Posts
Re: Why my collapsible Panel doesn't read the ClientID from my web User Control?
Nov 07, 2008 02:58 PM|LINK
First off, I'd suggest that you move your control loading code to the Page Init or the Page PreRender method instead of the Page Load method, like this: