Multiple user controls on Page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code on my aspx page

<%if(user_status==1){%><ctl:state1 runat="server" id="aaa"></ctl:state1><%}else if(user_status==2){%><ctl:state2 runat="server" id="bbb"></ctl:state2><%}else if(user_status==3){%><ctl:state3 runat="server" id="ccc"></ctl:state3><%}else if(user_status==4){%><ctl:state4 runat="server" id="ddd"></ctl:state4><%}%

When I load the page, all four controls are inilialized (page_loa
of each is fired

Question

Is is possible to avoid initializing all controls but the one that really should be
displayed

Thank
Michał Januszczyk
 
Michael,

I definitely would not approach this task as you would in legacy ASP. In
ASP.NET, you should not be placing conditional statements inline with your
HTML.

There are many solutions to your issue. One would be to add each user
control into a Panel control and then set the Visibility of the Panel to
specify whether or not it is rendered.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.



--------------------
Thread-Topic: Multiple user controls on Page
thread-index: AcQdgJui6xU0pp9ARyKt/6JfuUMbCw==
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
From: =?Utf-8?B?TWljaGHFgiBKYW51c3pjenlr?=
Subject: Multiple user controls on Page
Date: Thu, 8 Apr 2004 08:46:07 -0700
Lines: 16
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:224448
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

I have the following code on my aspx page:

<%if(user_status==1){%><ctl:state1 runat="server"
id="aaa"></ctl:state1><%}else if(user_status==2){%><ctl:state2
runat="server" id="bbb"></ctl:state2><%}else
if(user_status==3){%><ctl:state3 runat="server"
id="ccc"></ctl:state3><%}else if(user_status==4){%><ctl:state4
runat="server" id="ddd"></ctl:state4><%}%>


When I load the page, all four controls are inilialized (page_load
of each is fired)

Question:

Is is possible to avoid initializing all controls but the one that really
should be
displayed ?


Thanks
Michał Januszczyk
 
Back
Top