Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 20th, 2014, 07:10 PM
Authorized User
 
Join Date: Aug 2011
Posts: 44
Thanks: 14
Thanked 0 Times in 0 Posts
Default ViewStateMode and EnableViewState properties

Hello Imar,

in chapter 4, you explain the ASP.NET state engine.

Why there are two overlapping properties to set the view state of server controls - I mean ViewStateMode and EnableViewState - and not just one ?

Why the TextBox control has both properties despite it does not use view state to maintain its value ?


Thank you

Antonius
 
Old December 21st, 2014, 11:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Antonius,

1) This is for legacy reasons. EnableViewState has been in the framework forever. When ViewStateMode was implemented, the designers of ASP.NET couldn't modify the behavior of EnableViewState as that would have broken millions of sites. That's why they introduced the new property to give you more control.

2) The properties are implemented on the base Control so all controls inherit them. TextBox *can* use View State; it just doesn't need it to keep track of the value the user supplies when posting back. If you set up, say, a TextChanged event handler, ViewState is used to store the old value so ASP.NET can compare the old and new value on the server and raise the event when the data is different.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Session state and ViewStateMode arius ASP.NET 4 General Discussion 2 April 10th, 2013 07:51 AM
Can't find property EnableViewState in Try it out bulled 11, page 131 bjork BOOK: Beginning ASP.NET 4 : in C# and VB 6 April 13th, 2012 03:35 PM
builtindocument properties (Custom properties) swap555in BOOK: Excel 2003 VBA Programmer's Reference 0 May 25th, 2009 10:45 PM
GridView OnRowDataBound & Page.EnableViewState pvasudevan ASP.NET 2.0 Professional 0 November 20th, 2008 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.