beginner's question about asp.net

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
 
E

Edge

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.
 
P

pei_world

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);
 
F

Fabio

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top