I'm getting into dynamic user controls...nothing overly complicated
but I'm stuck.
I've got 5-10 pages that have the exact same function but look different
depending on a querystring value. So my thought was to create one
custom control that has all the functions and use it as my base class for the
rest.
I've got one page with a Placeholder control and in that control I want
to load these user controls based on said querystring
value. I'm getting the correct control to load and display like I
want but when the form is submitted (using a Button WebControl) and posted
back to itself it never reaches the button's OnClick event within
the user control code-behind.
I've read a few article like Scott's but I'm not
sure how it apply's to my situation. If I drop the user control on the
form at design time and forgo the dynamic piece everything works as
expected.
Someone learn me something.
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
string ID = Request.QueryString["id"];
string controlName = ID + ".ascx";
UserControl PostDataControl = (UserControl)LoadControl(controlName);
FormPlaceHolder.Controls.Add(PostDataControl);
}
}