473,767 Members | 7,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic Controls and View State

Dear All,
We all always have a problem dynamic controls and
ViewState...Sup pose 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 :
SaveCtrlViewSta te(id, val) { ViewState[id] = val }
GetCtrlViewStat e(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
GetCtrlViewStat e.

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 1492
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.goo gle.com...
Dear All,
We all always have a problem dynamic controls and
ViewState...Sup pose 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 :
SaveCtrlViewSta te(id, val) { ViewState[id] = val }
GetCtrlViewStat e(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
GetCtrlViewStat e.

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
8792
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, examples where something like a simulation model running in its own thread sends fast updates to a GUI in near real-time. The only examples I've seen, such as SimPy, wait until the model is finished running before outputting data.
1
17672
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 Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
9
17626
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: <>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<> <>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<> .NET Framework Class Library Control.Init Event
1
7587
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 dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
0
1701
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 single worksheet into a dataset. I successfully built a dynamic datagrid. And I did successfully bind it to the dataset. Then I added the datagrid control to a PlaceHolder. The first worksheet displays beautifully. The next step is to allow...
2
1428
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 run on a Windows Server 2003 IIS web farm utilising either MSDE Database or SQL Server Database. I’m developing this application utilising Microsoft’s Development Environment 2002 version.
1
1835
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 GridDataLangs(DataTable vDataTable){ DataGrid myGrid = new DataGrid(); myGrid.AutoGenerateColumns = false;
3
1722
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 and get some data from a dataset and then from it's contents build the page At this point the page is rendered and 2 rows are displayed. There is an Add button that a user can click to add another row to the table. This works fine and the row...
4
3864
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 to their clients in company correspondence. Using just name as an example, one rep might have a choice between "James Smith", "James Smith MS, CFP, MBA" and "Jimmy Smith" while a different rep might have only "Elizabeth Jones" and "Liz Jones."...
0
1142
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 selected control_click, do a page redirect to itself, putting in the url the new selected control.
0
9575
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10014
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8840
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6656
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3931
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.