Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 24th, 2012, 10:32 AM
Friend of Wrox
Points: 1,905, Level: 17
Points: 1,905, Level: 17 Points: 1,905, Level: 17 Points: 1,905, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default The View State Issue

On page 292 of your book you state:
"Removing the check for Page.IsPostback is enough to accomplish this. However this is not always the desired solution. Imagine that you are getting correct display direction from a database. Because the number of times that you hit a database can be a costly operation, you want to minimize the number of times that you hit the database."

My question to you would be is not Viewstate a pricely and cumbersome overhead to the overall footprint of the application as well? Can Viewstate not also have a tendency to gum up the works so to speak on any .NET application?

Thank you for your attention to this matter.
Reply With Quote
  #2 (permalink)  
Old January 24th, 2012, 10:37 AM
Friend of Wrox
Points: 1,905, Level: 17
Points: 1,905, Level: 17 Points: 1,905, Level: 17 Points: 1,905, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default

Quote:
Originally Posted by vbboyd View Post
On page 292 of your book you state:
"Removing the check for Page.IsPostback is enough to accomplish this. However this is not always the desired solution. Imagine that you are getting correct display direction from a database. Because the number of times that you hit a database can be a costly operation, you want to minimize the number of times that you hit the database."

My question to you would be is not Viewstate a pricely and cumbersome overhead to the overall footprint of the application as well? Can Viewstate not also have a tendency to gum up the works so to speak on any .NET application?

Thank you for your attention to this matter.
I guess maybe I should clarify my question just a bit more. The real question becomes what factors do you use to balance using viewstate as opposed to hitting the database? Are there any hard and fast rules in .NET for any of this when making these considerations?
Reply With Quote
  #3 (permalink)  
Old January 27th, 2012, 09:06 AM
Imar's Avatar
Wrox Author
Points: 71,662, Level: 100
Points: 71,662, Level: 100 Points: 71,662, Level: 100 Points: 71,662, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,015
Thanks: 79
Thanked 1,578 Times in 1,555 Posts
Default

Quote:
Are there any hard and fast rules in .NET for any of this when making these considerations?
No. You need to outweigh the pros and cons. If it's not directly clear, you'll need to measure performance and network trafic.

A complex number that takes 1 minute to calculate but only takes up the size of an integer is a good candidate to store in ViewState (if it doesn't have to be updated each time). A DataSet with 4000 records is clearly not a good candidate to store in ViewState. You could store it in the Cache, recreate it after each postback, or find ways to query fewer records on each call (but still not store them in ViewState).

Hope this helps a bit.

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!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
View state problem rabbit3 ASP.NET 2.0 Professional 0 October 23rd, 2007 08:55 PM
Javascript and View State VictorVictor ASP.NET 2.0 Professional 8 April 2nd, 2007 02:34 PM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM



All times are GMT -4. The time now is 10:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.