I have multiple user controls that I want to load into a base page. Example: private void Page_Load(object sender, System.EventArgs e) { Control c1 = LoadControl("controls/header.ascx"); Page.Controls.Add(c1); Control c2 = LoadControl("controls/surveys.ascx");
Page.Controls.Add(c2); } c1 conatins a header image c2 contains a datagrid When I run the base page, it generates a javascript error in c2 in the postback function at the line - theform = document._ctl0:Form2;. see below... function __doPostBack(eventTarget,
eventArgument) { var theform; if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) { theform = document.forms["_ctl0:Form2"]; } else { theform = document._ctl0:Form2; } theform.__EVENTTARGET.value = eventTarget.split("$").join(":"); theform.__EVENTARGUMENT.value
= eventArgument; theform.submit(); } Is it because it is trying to reference the form before it is loaded?
falco777
Member
45 Points
9 Posts
Load multiple user controls programmatically
Aug 06, 2003 07:50 PM|LINK
daveym
Member
200 Points
40 Posts
Re: Load multiple user controls programmatically
Aug 07, 2003 08:12 AM|LINK