how to conditionaly add a usercontrol? (ASCX)

K

KK

Hi guys

I have two user controls (ascx)
I want to place them conditionaly
in my aspx page. How to do that?

For exmple,

If Request["variable"] = "1" then
DisplayASCXcontrol(1)
Else
DisplayASCXcontrol(2)
End If

So, according to the users choice
when the page loads, it will
contain one of the user controls.

rgds
KK
 
J

Jos Branders

KK said:
Hi guys

I have two user controls (ascx)
I want to place them conditionaly
in my aspx page. How to do that?

For exmple,

If Request["variable"] = "1" then
DisplayASCXcontrol(1)
Else
DisplayASCXcontrol(2)
End If

So, according to the users choice
when the page loads, it will
contain one of the user controls.

rgds
KK

Use the LoadControl method:
Page.LoadControl("control1.ascx")

See:
http://www.brettb.com/DynamicUserControlsWithLoadControl.asp
 

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

Members online

No members online now.

Forum statistics

Threads
473,890
Messages
2,569,971
Members
46,303
Latest member
subroihei

Latest Threads

Top