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

Technical ViewState question

Looong story, but here's the summary:

I'm dynamically generating a single TextBox control (always with the
same exact ID), but in a different location each time (there will be a
varying number of dynamically generated Labels before and after it).

As near as I can tell, when the control doesn't move it participates in
ViewState and it's data value persists between postbacks.

However, if it moves (there are more/fewer Labels before it than last
trip), it's data does not persist.

This surprises me. Although I don't understand ViewState on a deep
level, I thought data was persisted by the control's ID, not it's
relative position in the list of controls.
My questions:

Is ViewState data persisted by relative position, or by ID, or by some
other method?

Is it dangerous to be "moving" controls around like I am?

Is there a way to keep the data persistent (using ViewState) when the
control moves to a different location?
Thanks in advance for any help!

--Larry

Nov 19 '05 #1
2 980
Hi Larry:

Yes, the relative position of a control will change where the control's data
appears in the ViewState. There is good coverage of the topic here:

Understanding ASP.NET View State
http://msdn.microsoft.com/library/de.../viewstate.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/
Looong story, but here's the summary:

I'm dynamically generating a single TextBox control (always with the
same exact ID), but in a different location each time (there will be a
varying number of dynamically generated Labels before and after it).

As near as I can tell, when the control doesn't move it participates
in ViewState and it's data value persists between postbacks.

However, if it moves (there are more/fewer Labels before it than last
trip), it's data does not persist.

This surprises me. Although I don't understand ViewState on a deep
level, I thought data was persisted by the control's ID, not it's
relative position in the list of controls.

My questions:

Is ViewState data persisted by relative position, or by ID, or by some
other method?

Is it dangerous to be "moving" controls around like I am?

Is there a way to keep the data persistent (using ViewState) when the
control moves to a different location?
Thanks in advance for any help!
--Larry

Nov 19 '05 #2
What a goldmine! Thanks a million, Scott.

--Larry

Nov 19 '05 #3

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

Similar topics

3
by: Kevin Gorski | last post by:
This question has been asked before, but there have been no definitive answers that I was able to find. Can the viewstate hidden input field be moved to a less prominent page location? On an...
1
by: Simon | last post by:
Hi everyone, I have a quick question that I hope someone can help me with: I've made a user control that contains a text box and some validation functionality. This control has a few extra...
7
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
6
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a...
9
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct...
1
by: Mark Olbert | last post by:
I have a "master" composite control which, in turn, holds an instance of a "detail" composite control (the "master" control will ultimately contain multiple instances of the "detail" control, but...
3
by: Justin | last post by:
I have aspx pages with 10 checkboxlist controls. total individual checkbox (the sum of individual checbox in those 10 checkboxlists) on the page is about 1710. You can imagine how large the...
9
by: =?Utf-8?B?TUNN?= | last post by:
I'm sure the answer to my question varies depending on the situation, but I am looking for a general "best practice". If I have an asp.net application and I load certain data from a database,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...
0
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,...
0
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...
0
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...

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.