473,395 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Multiple User Controls per page

Hi,
I have a page that will need to dynamically use 4 different user controls
based on a Query String passed to it.
Currently I have the @Register for each control and the <tagprefix: tagname>
in a case statement depending on the quesry string. However, when the page
is loaded, all 4 user controls seem to be compiled and instantiated when the
page runs. Therefore causing various problems when submitting the page.

Is there a way to conditionally load a user control based on a querystring?

Thank you in advance
David

Aug 3 '05 #1
3 1728
I would suggest creating the controls dynamically at runtime based on your
query string params. Just place a Panel control on your page. Then during
runtime you can create your user controls and add them to it's controls
collection.
=====================
David McCarter
www.vsdntips.com
"David" wrote:
Hi,
I have a page that will need to dynamically use 4 different user controls
based on a Query String passed to it.
Currently I have the @Register for each control and the <tagprefix: tagname>
in a case statement depending on the quesry string. However, when the page
is loaded, all 4 user controls seem to be compiled and instantiated when the
page runs. Therefore causing various problems when submitting the page.

Is there a way to conditionally load a user control based on a querystring?

Thank you in advance
David

Aug 3 '05 #2
Thanks David
Any examples on how to accomplish this?

"dotNetDave" wrote:
I would suggest creating the controls dynamically at runtime based on your
query string params. Just place a Panel control on your page. Then during
runtime you can create your user controls and add them to it's controls
collection.
=====================
David McCarter
www.vsdntips.com
"David" wrote:
Hi,
I have a page that will need to dynamically use 4 different user controls
based on a Query String passed to it.
Currently I have the @Register for each control and the <tagprefix: tagname>
in a case statement depending on the quesry string. However, when the page
is loaded, all 4 user controls seem to be compiled and instantiated when the
page runs. Therefore causing various problems when submitting the page.

Is there a way to conditionally load a user control based on a querystring?

Thank you in advance
David

Aug 3 '05 #3
The only code I could quicly find was from a class I teached at UCSD. It uses
a table instead of a panel, but it's the same priciple. Here is some of the
code:

tr = New TableRow()
td = New TableCell()
Dim img As New ImageButton()
img.ImageUrl = "images/" & file
td.Controls.Add(img)
td.HorizontalAlign = HorizontalAlign.Center
tr.Cells.Add(td)
tbl.Rows.Add(tr)

The important piece of code is "td.Controls.Add()". All container controls
have this method so that you can, at design time, create a control object and
add it to the collection.

Let me know if you have any further questions.
David

"David" wrote:
Thanks David
Any examples on how to accomplish this?

"dotNetDave" wrote:
I would suggest creating the controls dynamically at runtime based on your
query string params. Just place a Panel control on your page. Then during
runtime you can create your user controls and add them to it's controls
collection.
=====================
David McCarter
www.vsdntips.com
"David" wrote:
Hi,
I have a page that will need to dynamically use 4 different user controls
based on a Query String passed to it.
Currently I have the @Register for each control and the <tagprefix: tagname>
in a case statement depending on the quesry string. However, when the page
is loaded, all 4 user controls seem to be compiled and instantiated when the
page runs. Therefore causing various problems when submitting the page.

Is there a way to conditionally load a user control based on a querystring?

Thank you in advance
David

Aug 3 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: .Net Newbie | last post by:
I am relatively new to .Net and have been coding an intranet site for my employer for a couple of months. I am currently stuck coding in a text-editor called EditPlus without access to the VS.Net...
3
by: Damon | last post by:
I am working on a site in which I would like to have two dropdowns that will allow a user to navigate through the administrative pages of the site. The first would allow the user to choose the...
1
by: MichaƂ Januszczyk | last post by:
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"...
2
by: ScottOnes | last post by:
Hi I have a placeholder that has multiple controls that need to be loaded and rendered to the user based on some user selections. I have to loop through the choices that the user makes and then...
3
by: Nathan Sokalski | last post by:
When I view any page in my application a second time, I recieve the following error: System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize) +313...
1
by: SteveComplex | last post by:
I'm currently working on a project developing a web application that makes heavy use of 3rd-party controls, popup windows and frames ( not my design I hasten to add ). Some of the pages make use...
11
by: Ranginald | last post by:
This question is about how to handle an .aspx page that references multiple methods and where to store these methods (e.g. one codefile or multiple codefiles). PREFACE ======== I have a simple...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
1
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business...
4
by: Greg | last post by:
I have a complex page (with 8 complex user controls, and many other asp.net controls.) I have 2 very similiar pages to create, each page differing only from the others in one control. What is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.