|
|
||||||
|
#1
|
|
|
|
|
Dear All,
We all always have a problem dynamic controls and ViewState...Suppose we want to create dynamic Controls on Load of the page and Save its value in the ViewState and get them back, will it be asking for too much...I guess no...:-) I have found a solution that I want to share in this newsgroup... 1. Write a page Class 'basePage.cs'. 2. In this page class write two functions : SaveCtrlViewState(id, val) { ViewState[id] = val } GetCtrlViewState(id, val) { val = ViewState[id] } 3. Derive your page from this page class. 4. Define your control and instead of saving the information in its ViewState call the above function using reflection. 5. When you want the ViewState value of that control just call the page's GetCtrlViewState. I found this workflow very simple and easy to use. Have I overlooked any major mistakes? Paul Wilson: It would be nice to have your comments too regarding this. Thanks & Regards Sunil |
|
|
|
#2
|
|
|
|
|
I assume basePage.cs derives from Page. I see nothing wrong with this
methodology, as it is very similar to what is happening beneath the hood. |
|
|
| 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... |
|
| Handling view state with Dynamic controls 1) I build a Html Table dynamically (Header Row, and then 2 rows with data All 2 rows have 2 cells: cell(0) contains a delete button (ASP Button), cell(1) contains a HTML... |
|
| View State issue with dynamically added controls-Plz help :-) I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I... |
|
| Dynamic User Control and the View State Hi, I'm trying to load a WebUserControl (.ascx) into a PlaceHolder but I keep getting an exception that the Page Tree ViewState is modified. If I load the WebUserControl by... |
|
| maintaining state for dynamic controls between PostBack() ??? Hi all. Relative newcomer to asp.net. I am constructing an asp.net/C# app that requires some metadata-based dynamic form creation (shows only those product details required... |
|
|
All times are GMT. The time now is 02:45 PM. | Privacy Policy
|