beginner's question about asp.net

  • Thread starter Thread starter pei_world
  • Start date Start date
P

pei_world

I want to insert my usercontrol in to the middle of my template page
according to switch case. something like

[Register.aspx]

switch(i){
case 0: insert usercontrol1
break;
case 1: insert usercontrol2
}

how can I control where to display this usercontrol in my page??

please help
 
pei_world said:
I want to insert my usercontrol in to the middle of my template page
according to switch case. something like

[Register.aspx]

switch(i){
case 0: insert usercontrol1
break;
case 1: insert usercontrol2
}

how can I control where to display this usercontrol in my page??

please help

This is what the placeholder control is for.
Add placeholders where your usercontrol might appear,
then from code, add the usercontrol to the right placeholder.
 
I try to use this code, however it can not display.
phContent is PlaceHolder

System.Web.UI.UserControl cy =
(UserControl)LoadControl("IncludeFiles/country.ascx");
phContent.Controls.Add(cy);
 
pei_world said:
I try to use this code, however it can not display.
phContent is PlaceHolder

System.Web.UI.UserControl cy =
(UserControl)LoadControl("IncludeFiles/country.ascx");
phContent.Controls.Add(cy);

Replace UserControl with the name of the class defined in country.ascx.
 
Back
Top