|
|
||||||
|
#1
|
|
|
|
|
Hello,
I am loading several user controls dynamically in OnInit() like this: ucListBoxSelections ucLocation = (ucListBoxSelections)LoadControl("UserControls/ucListBoxSelections.ascx"); ucListBoxSelections ucDept = (ucListBoxSelections)LoadControl("UserControls/ucListBoxSelections.ascx"); ucListBoxSelections ucBusiness = (ucListBoxSelections)LoadControl("UserControls/ucListBoxSelections.ascx"); PlaceHolder1.Controls.Add(ucLocation); PlaceHolder1.Controls.Add(ucDept); PlaceHolder1.Controls.Add(ucBusiness); Then, in the Page_Load I thought I should be able to access these Controls and reload (or assign for the first time) its data through the ViewState (that has not been lost because it was loaded in OnInit(). Am I doing this correctly because I cannot "find" these Controls in Page_Load? Also, each time I click on any one of these User Controls there is a postback, as expected, but all the listboxes (in each of the user controls) still seems slow to load. I assume that is because they are reloading. The idea, I thought, was that it was faster to load these controls in OnInit. I think I am close, does anyone have some suggestions? Thank you. p.s. There are several user controls that get loaded each time. However, they do not have to be dynamic because they will always appear on the page. It's just their data in their listboxes will change. Is there a better way to approach this? |
|
|
|
#2
|
|
|
|
|
Here is a starter article to read:
http://msdn2.microsoft.com/en-us/library/ms178472.aspx This article describes the ASP.NET Page LifeCycle. It describes how everything is built when you request an asp.net page and in what order. IIRC, You should be able to access the controls in the Page_Load method, at this point OnLoad is called and postback data is loaded into the controls. So you should be able to. I apologize for the vagueness of the post, its been a little while since I've played with dynamic controls so my mind is a little fuzzy. Take a look at that article though, that should point you in the right direction. Gummy wrote: [..] |
|
|
| Similar Threads | |
| Dynamic controls, postbacks, and view state My application calls for a lookup table in which the user can add records. When the application is run, an html table will be created dynamically to show checkboxes (and... |
|
| dynamic controls & viewstate Hi, I am attempting to create a questionnaire dynamically in an asp.net webform. I have a repeater control which is bound to my datasource, the repeater has a placeholder... |
|
| Persisting dynamic controls across postbacks.... Hi, I am creating a control in a PlaceHolder like so: Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim... |
|
| Viewstate and dynamic controls I have a form with two dynamically created controls. One control is a list box, the other is a text box. I would like to set the value of the text box based on the... |
|
| Dynamic runtime controls, postbacks, Page_Init, Viewstate et al Hi, I've searched the newsgroup and other sources to understand how to handle runtime controls and see I'm not the only one who's confused, but I'm still not quite sure of... |
|
|
All times are GMT. The time now is 04:40 PM. | Privacy Policy
|