C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

ViewState and Performance


Posted Date: 11 Jun 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Lokanathan Member Level: Bronze    
Rating: 1 out of 5Points: 7



This article explains about View State. ViewState has its own benefits and limitations. Performance of the page depends on the efficient usage of ViewState.


Web Forms pages and controls all have a ViewState property, which is a built-in structure for automatically retaining values among multiple requests for the same page. The view state is internally maintained as a hidden field on the page but is hashed, providing greater security than developer-implemented hidden fields do.

You can use view state to store your own page-specific values across roundtrips when the page posts back to itself. For example, if your application is maintaining user-specific information, such as a user name that is displayed in a welcome message, you can store the information in the ViewState property.

Performance of view state varies depending on the type of server control to which it is applied. Label, TextBox, CheckBox, RadioButton, and HyperLink are server controls that perform well with ViewState. DropDownList, ListBox, DataGrid, and DataList suffer from poor performance because of their size and the large amounts of data making roundtrips to the server.

In some situations, using view state is not recommended because it can degrade performance.

For example:


  • Avoid using view state in pages that do not post back to the server, such as logon
    pages.
  • Avoid using view state for large data items, such as DataSets, because doing so
    increases time in roundtrips to the server.
  • Avoid using view state when session timeout is required because you cannot time
    out data stored in the ViewState property.
  • View state is a simple and easy-to-use implementation of hidden fields that provides some security features. Most of the performance considerations, benefits, and
    limitations of view state and hidden fields are similar.


    Benefits and Limitations of View State

    The benefits of using view state include:

  • No server resources are required because state is contained in a structure in the page code.
  • It is simple to implement.
  • Pages and control state are automatically retained.
  • The values in view state are hashed, compressed, and encoded, thus representing a higher state of security than hidden fields.
  • View state is good for caching data in Web farm configurations because the data is cached on the client.

    Limitations to using view state include:


  • Page loading and posting performance decreases when large values are stored
    because view state is stored in the page.
  • Although view state stores data in a hashed format, it can still be tampered with because it is stored in a hidden field on the page. The information in the hidden field can also be seen if the page output source is viewed directly, creating a potential security risk.


    Now we are aware of the benefits & limitations of viewstate.When it comes to the performance of the Page consider using the ViewState.

    To know more abt "How To increase Performance and Scalability in .Net Applications"

    visit: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenet.asp

    And To understand abt Caching Technologies

    visit:




  • Responses

    Author: Govindu Pradeep Kumar Reddy    11 Jun 2004Member Level: Bronze   Points : 0
    I'm appreciating You. Continue...


    Author: Zainul Husain    11 Jun 2004Member Level: Bronze   Points : 0
    Excellet Info - Thanks


    Author: Zainul Husain    11 Jun 2004Member Level: Bronze   Points : 0
    Excellent Info - Thanks


    Author: critic    11 Jun 2004Member Level: Bronze   Points : 0
    I agree that it is an excellent work - thats why Microsoft included it in the patterns & Practices !! View the original article here : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/CachingArchch2.asp

    Don't copy man! Try to write your own....


    Author: Lokanathan     12 Jun 2004Member Level: Bronze   Points : 0
    Yes You are right Mr Critic. But my only point is we have to make info and tips to reach the readers of dotnetspider. Nothing else.

    In this article, there was no need for customizing the info for easy understanding. Itz straight forward.

    When it comes to include examples/code snippets for the better understanding, definitely i will do.

    The good thing i have missed is giving the link to visit the original section in the Microsoft Site.

    That i have added now to my tip/article.

    Thanks for your critic & feedback.



    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    (No tags found.)

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Change the datagrid footer text
    Previous Resource: Displaying the Records in DataGrid from Ascending to Descending and Viceversa
    Return to Discussion Resource Index
    Post New Resource
    Category: ASP.NET/Web Applications


    Post resources and earn money!
     
    Related Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use