Groups | Blog | Home
all groups > asp.net webcontrols > november 2004 >

asp.net webcontrols : how to conditionaly add a usercontrol? (ASCX)


Jos Branders
11/27/2004 5:50:40 PM
[quoted text, click to view]

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

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

--

Jos

KK
11/27/2004 8:40:24 PM
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


Leon Friesema
11/30/2004 7:20:20 PM
On Sat, 27 Nov 2004 17:50:40 +0100, "Jos Branders"
[quoted text, click to view]

Or.. place both Ascx's on the webpage, set visible to false and set
the visible to true if neccesary:

this.FindControl('control1.ascx').Visible = true;

That way you have more control on layout etc., but you need to hide
the other control all the same.

AddThis Social Bookmark Button