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

Dynamic Controls and View State

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
Nov 17 '05 #1
1 1479
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.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Sunil Menon" <su***@itb-india.com> wrote in message
news:de**************************@posting.google.c om...
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

Nov 17 '05 #2

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

Similar topics

7
by: pysim | last post by:
Hi, I have a couple of general requests for pointers to python examples and design advice. I'm looking for examples of MVC-based GUI controls done in python (model-view-controller). Also,...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
9
by: wASP | last post by:
Hello again to all of you geniuses, I'm having a problem trying to load dynamic controls at the initialization phase. I've read the docs, and I thought I had it figured out:...
1
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) MainPage_load 2) User control1_Load user clicks a...
0
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a...
2
by: geodev | last post by:
Hello, I’m currently writing an asp.net application that will be running on a Windows XP Professional workstation utilising IIS and MSDE Database. At a later date this application will need to...
1
by: benoit | last post by:
Hi, I created a Dynamic Datagrid and i added an EditCommandColumn to it. Works fine, but my Editcommand eventhandler seems to have a problem with PostBack This is my code private DataGrid...
3
by: gaDev | last post by:
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 Text box 2) On Form Load...
4
by: Gregory Gadow | last post by:
If there is a more appropriate forum, please let me know and I will post there. Our field reps can go on to our website and select from several sets of data to create the address we then provide...
0
by: Francois | last post by:
I have to modify existing code : Basically, it implemnts tabbed forms. On the pageLoad, the code creates the two selection controls, plus kind of page depending of selected control. On...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.