Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

Static Variable vs View State

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nil - 09 Apr 2008 11:55 GMT
Hi,
  I am facing problem with the huge Viewstate size(Using .NET 2.0).
  to improve the application performance,
  I am using Static variable to store view state data.
Does anyone has other option to improve performance or what r drawback of
using Static variable.

Thanks,
Nil
Hans Kesting - 09 Apr 2008 13:17 GMT
Nil formulated on woensdag :
> Hi,
>    I am facing problem with the huge Viewstate size(Using .NET 2.0).
[quoted text clipped - 5 lines]
> Thanks,
> Nil

One thing to watch out for is that a static variable is visible to ALL
users. So do not store user-specific information in it: you will
overwrite the info of the other users.

You can always set EnableViewState to "false" for all controls where
you don't use it.

Or maybe use the SessionPageStatePersister class (never used it myself)
http://msdn2.microsoft.com/en-us/library/system.web.ui.sessionpagestatepersister
(VS.80).aspx


Hans Kesting
George Ter-Saakov - 09 Apr 2008 13:55 GMT
They kind of not interchangeable.....
ViewState is per browser/request and static variable is the same for all
users.
You can look up on Google how to keep ViewState in a Session so it's not
passed to browser back and force...

But it's better to find another solution...

George.

> Hi,
>   I am facing problem with the huge Viewstate size(Using .NET 2.0).
[quoted text clipped - 5 lines]
> Thanks,
> Nil
Peter Bromberg [C# MVP] - 09 Apr 2008 18:38 GMT
I agree with Hans. First you want to reduce the size of Viewstate as much as
possible.
Second, store it on the server with the SessionPageStatePersister. I wrote
up a short article on this that illustrates how easy it is:

http://www.eggheadcafe.com/tutorials/aspnet/b48875f6-525b-4267-a3a8-64dd33bfc2fe
/keep-viewstate-out-of-pag.aspx

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net

> Hi,
>    I am facing problem with the huge Viewstate size(Using .NET 2.0).
[quoted text clipped - 5 lines]
> Thanks,
> Nil

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.