Solved

input control values get persisted in postback WITHOUT viewstate ?

Posted on 2009-05-14
8
253 Views
Last Modified: 2012-05-07
A few weeks into ASP.net and a newbie question...

Have I got this right ?

In an *.aspx page, as long as the <form> is set to runat="server", then ANY (i.e. HTML, web-) controls with runat="server" will have their last/current values reset after a postback occurs
..(and here's the key..).. WITHOUT needing viewstate enabled

IE when the page gets submitted to itself ASP.NET uses the form data to see what the current values of the controls are, and if they are runat=server, sets them to the same value in the new page ?

THEREFORE: viewstate is only needed for control info that is NOT sent in form data, e.g. color, font etc. (or for controls not marked as runat=server, but why you'd want to do this.... etc. etc.), or for custom info the programmer adds to viewstate "manually"...

Empirically, by running tests, this seems to happen
However TWO books by Apress fail to mention this KEY FACT !!, apart from a few asides in UNRELATED chapters....

ALSO, can anyone point me to an official documentation (or failing that unofficial) that verifies this and explains/confirms it

many thanks!!
0
Comment
Question by:zorba111
  • 4
  • 4
8 Comments
 

Author Comment

by:zorba111
Comment Utility
this looks like a good UNOFFICIAL explanation

http://www.codeproject.com/KB/viewstate/ViewState.aspx

still holding out for Official docs, or more succinct unofficial explains
0
 
LVL 19

Accepted Solution

by:
daveamour earned 500 total points
Comment Utility
Viewstate has nothing to do with input controls maintaining inputted data.
This article is brilliant, a little long but well worth the read if you have time.
http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx
0
 

Author Comment

by:zorba111
Comment Utility
thanks Dave, that is a great article !!

I got 80% of it on first read, which movre than covered my questions. Now I feel like an ASP.net cognoscenti and which is not bad for 3 weeks in. oh my swelling head! :-)
0
 
LVL 19

Expert Comment

by:daveamour
Comment Utility
I've been doing asp.net for 7 years and still feel like a beginner!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:zorba111
Comment Utility
I know my feelings of imperiousness will not last long as no doubt I will hit another humbling problem quite soon - such is the way of tech

but for the moment I'm enjoying the conceit....
 :-)

thanks again for the pointer
0
 
LVL 19

Expert Comment

by:daveamour
Comment Utility
Your welcome and yes once youve learned everything it will all be obsolete!
0
 

Author Comment

by:zorba111
Comment Utility
you're right, how often these days have I had to create a COM object, implement an interface, or use an ATL ?

or for that matter hook into a windows message pump ?
or do memory management in Win32

many a weighty tome gathering dust on my shelf

LOL
0
 
LVL 19

Expert Comment

by:daveamour
Comment Utility
Yep they make great door stoppers or firewood!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now