473,387 Members | 1,542 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,387 software developers and data experts.

Page.LoadControl

Hi all
I have one page WebForm1.aspx and one user control UserControl.ascx
My WebForm1 has a Place holder and dropdownlist with autopostback property
set to true.

The user control also has a dropdownlist with autopostback property to true

One selecting Item1 from dropdownlist on Webform1 I want the user control to
be added to the place holder.
This works fine.

But when i select an item from the dropdownlist of the usercontrol, the user
control is not loaded.

So on any post back of the user control , I dont see the usercontrol on the
page

What should i do to see the usercontrol on the page all times

Thanks
Sekhar

Apr 17 '06 #1
2 1774
Every time the Page is posted back, the entire page and everything in it
must be created. Therefore, if you add any Control to the Page during a
PostBack, you have to re-add it and restore its state with each successive
PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"Sekhar" <Se****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
Hi all
I have one page WebForm1.aspx and one user control UserControl.ascx
My WebForm1 has a Place holder and dropdownlist with autopostback property
set to true.

The user control also has a dropdownlist with autopostback property to
true

One selecting Item1 from dropdownlist on Webform1 I want the user control
to
be added to the place holder.
This works fine.

But when i select an item from the dropdownlist of the usercontrol, the
user
control is not loaded.

So on any post back of the user control , I dont see the usercontrol on
the
page

What should i do to see the usercontrol on the page all times

Thanks
Sekhar

Apr 17 '06 #2
Hi,

All dynamically created controls need to be recreated on every post back.
This should be done in the page_init or page_load event. This is because on
post back the web server has no idea of any previously dynamically created
controls.

Once they are recreated its methods will then be invoked.

See the page lifecycle: http://msdn2.microsoft.com/en-US/library/ms178472.aspx

Regards
Warren

"Sekhar" wrote:
Hi all
I have one page WebForm1.aspx and one user control UserControl.ascx
My WebForm1 has a Place holder and dropdownlist with autopostback property
set to true.

The user control also has a dropdownlist with autopostback property to true

One selecting Item1 from dropdownlist on Webform1 I want the user control to
be added to the place holder.
This works fine.

But when i select an item from the dropdownlist of the usercontrol, the user
control is not loaded.

So on any post back of the user control , I dont see the usercontrol on the
page

What should i do to see the usercontrol on the page all times

Thanks
Sekhar

Apr 17 '06 #3

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

Similar topics

3
by: Tom | last post by:
Hi, I have an index.aspx page which includes top.aspx, left.aspx, main.aspx and bottom.aspx. In the left.aspx, there is a login web control - login.ascx. It keeps session of username and role...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
4
by: Christopher | last post by:
I am trying to load a UserControl which inherits from one of our customer classes which in turn inherits from UserControl. We use Page.LoadControl() from within our ASP.NET pages to load these...
4
by: Support | last post by:
Hello: I have a aspx web page - let's call it main.aspx It contains a placeholder: Myplaceholder. I have a web control, lets call it webcontrol which has a code behind class called...
5
by: alecyy | last post by:
hi, I create a UserControl called "RegInfo.ascx", then i add a PlaceHolder to WebForm1, and in WebForm1.Page_Load() i wrote the follow statement: placeHolder.Controls.Add(new RegInfo()); but...
5
by: Jay Douglas | last post by:
I have a set of pages that inherit from a base class in the App_Code folder. The class looks something like: public class MyBaseClass : System.Web.UI.Page In various stages of the life cycle I...
1
by: Joe | last post by:
Hello All, I have a class that inherits from System.Web.UI.Page. In it I call the Page.LoadControl. I am having trouble with the virtual path that the LoadControl method accepts as its...
1
by: RSH | last post by:
Hi, I have a situation where I have a user Control (ResultHeader.ascx) that has a button. I am placing that control into a page (samplePage.aspx). I have setup a custom event, that should from...
1
by: pyrusmagnus | last post by:
Hi, I'm having trouble loading a user control from inside my Sharepoint webpart. A System.IO.FileNotFoundException occurs on this line: Control myControl = Page.LoadControl("/UserControls/...
2
by: =?Utf-8?B?SlQtQVJM?= | last post by:
I have a pretty tricky problem. I have a dynamically built page. I use Page.ParseControls to parse the "entire page" (ASPX file contains only a Page tag). ParseControls is pretty resource...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.