473,387 Members | 1,512 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.

UserControl and Postback

Hello,

I am developing a webpage (in .net 2003) that requires several
complicated user webcontrols to load different modules within the page.
Most of these webcontrols are loaded are runtime. Based on some action
(button-click) on these additional custom controls may be added or
removed from the page. The issue I am facing is that I am having to
load these dynamic controls everytime in Page_Load and as a result the
state of the control gets lost. Also, since Page_Load happens before
Button_Click event I am having to do Server.Transfer to reload some of
the data in the page.

Is there any better way to execute this in ASP.Net 1.1?

Thanks.

Mar 13 '06 #1
3 1313
What type of data are you holding in these controls?

If you just need to save a few pieces of information, you could save
the information to Session["myVar"], and then retrieve the value on
postback.

Mar 13 '06 #2
Yes, that's what I am doing now but, I am having to reload the
webcontrols everytime the page is loaded and set each and every value
from the session. Plus since the Button_Click event occurs after
Page_Load it is creating more problems forcing me to add the user
controls once in the Button_Click event and then again in the Page_Load
event. I am just wondering if there is a better cleaner way to handle
such situations.

Thanks.

Mar 13 '06 #3
Are you familiar with the PreRender event? Try using the PreRender event
instead of page_load to access your control variables. You would still
dynamically assign the controls on the server in page_load. Assuming that
the Custom controls are maintaining its state correctly internally, due to
the Asp.net page event model, the user controls will not have loaded the
retained viewstate until the PreRender event fires (which is after the
page_load event). The effect of this would appear like the control has lost
its state when accessed in page_load. Accessing your control parameters in
the PreRender event may take care of your need to manually reload the
controls.

"su*****@gmail.com" wrote:
Hello,

I am developing a webpage (in .net 2003) that requires several
complicated user webcontrols to load different modules within the page.
Most of these webcontrols are loaded are runtime. Based on some action
(button-click) on these additional custom controls may be added or
removed from the page. The issue I am facing is that I am having to
load these dynamic controls everytime in Page_Load and as a result the
state of the control gets lost. Also, since Page_Load happens before
Button_Click event I am having to do Server.Transfer to reload some of
the data in the page.

Is there any better way to execute this in ASP.Net 1.1?

Thanks.

Mar 14 '06 #4

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

Similar topics

4
by: Dan | last post by:
Hi, I have a UserControl that contain : 1 treeview 1 datagrid and so on ... Is there a way to postback ONLY ONE control and not all content in my Usercontrol ? (because all contents in my...
8
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
9
by: Anders K. Jacobsen [DK] | last post by:
Hi I have this that adds some usercontrol (UCTodays.ascx) to a placeholder foreach(A a in B){ UCTodays ucline = (UCTodays )LoadControl("UCTodays.ascx");...
2
by: Tim_Mac | last post by:
hi, i have an aspx page which dynamically loads a user control and adds it to a placeholder. the control is recreated and added to the placeholder for postbacks as well. the user control...
1
by: Will Gillen | last post by:
I know this has probably been asked before, but I can't seem to find a solid answer in any of the archives. First, before my question, please forgive my limited knowledge of the event lifecycle...
0
by: gregfocker | last post by:
I'm playing w/this sample: http://ajax.asp.net/docs/tutorials/CreateSimpleAJAXApplication.aspx and am trying to get this to work in a UserControl. Clicking to select a different page of data...
2
by: acadam | last post by:
In my application I have a usercontrol called "base" with a panel called "pnl1"; in "pnl1" I put my usercontrol. Now I would like to have 2 possibilities: from "base" to load another control...
1
by: stimul8d | last post by:
okay; ASP. I have i listbox inside a user control which is dynamically created on page_init. I check for postback and only populate the datasource if it's false. regardless, i do this ...
5
by: Leon Mayne | last post by:
Having a bit of trouble here. I know that if you want to use a fileupload control inside an AJAX update panel then you need to create a trigger for the control that performs the uploading postback...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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.