472,353 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Dynamic loading of Usercontrol problem


I am trying to create an webform which loads usercontrols
dyanamically. I know exactly what to load for some of these controls
but for some, I dont want to load it until the user has press a

The controls which I know I will need at page init gets their
viewstate contents back properly per postback. However I am having a
lot of troubles with keeping the contents of usercontrols which are
only loaded when user clicks on a button. They don't seem to keep
their contents entered by the user after a postback.

I know that you are supposed to loadcontrols at page_init , so I
thought that maybe it was due to loading of the usercontrol at the
button click event causing this problem. So I have moved it loading of
them to page_init on condition of a state set when user clicks on

Is this problem because of my instance of the usercontrol is not kept
for reloading, so in effect , I am loading a brand new control
everyttime? I have problems keeping reference of the userscontrol
between postback because I have a webfarm here, so I think thats the
reason for example caching not working to well.

I am having fierce troubles here. Can someone please shed some light
here? Share some sample code etc. The below is briefly what I am

Heres the code invloved. The RecreateControl is what I call from
page_init. This creates the necessary controls on page load on
postback. I am losing user input per psotback.

private void ReCreateControls()
if(btnEditProfile.Text == btnOn)


private void LoadProfile()
// Load the User Control
Control uc = LoadControl("EditProfile.ascx");
// Add the User Control to the Controls collection
private void LoadTicketInfo()
ArrayList TicketInfo = BLL.TicketInfo.GetTicketInfo(2);


//create ticket
foreach(BLL.TicketInfo ti in TicketInfo)

Control uc = LoadControl(ti.UserControlName);

// Add the User Control to the Controls collection
Control c = Page.FindContro(ti.PlaceHolderName);
Page.FindControl(ti.PlaceHolderName).Controls.Add( uc);


Nov 18 '05 #1
0 1432

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

Similar topics

by: tascien | last post by:
I have a user control that has dynamic controls loaded to it in Page_Init. this works well. I have a function inside the user control: ...
by: Sundaresan | last post by:
I've a form where I load two user controls dynamically. User Control-1 has a no.of dropdowns and based on the selection I typically populate a...
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1)...
by: John | last post by:
Hi all, I need finality on this once and for all please. I have a main page which contains a couple of placeholders and within these...
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public...
by: Lloyd Sheen | last post by:
Ok I have created a small testbed site for testing and I am have a problem with the terms Usercontrol, Webcontrol, etc. What I need to do in the...
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site....
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load...
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.