is there any way to avoid __VIEWSTATE hidden field in the page

Discussion in 'ASP .Net' started by reju, Mar 6, 2007.

  1. reju

    reju Guest

    Hi,

    I am not using view state.I disabled the view state, but this hidden
    __VIEWSTATE variable and some text is coming when we are taking the
    view source.Is there any way to remove this variable?

    Reju
     
    reju, Mar 6, 2007
    #1
    1. Advertisements

  2. reju

    Guest Guest

    Hi

    You just cant get rid completely of the __VIEWSTATE field, it will always
    contain a few bytes that are used internally and dont relate to your
    control's state.

    Adlai
    -------------------------------------
    If my answer helped you please press "Yes" bellow

    ×× ×ª×©×•×‘×” זו עזרה לך, ×× × ×”×¦×‘×¢ "כן"

    Adlai Maschiach
    http://blogs.microsoft.co.il/blogs/adlaim/
     
    Guest, Mar 6, 2007
    #2
    1. Advertisements

  3. reju

    Kevin Guest

    You can override two page methods (available in ASP.NET 2.0) -
    Page.LoadPageStateFromPersistenceMedium() and
    Page.SavePageStateToPersistenceMedium(viewState) to store viewstate in
    Session / Cache / SQL with the need to send it to the client (by
    default). More info can be found here:

    http://www.codeproject.com/aspnet/PersistentStatePage.asp
     
    Kevin, Mar 6, 2007
    #3
  4. Set EnableViewState to false in the page directive or in the app's web.config.

    Per page (in directive) : <%@ Page EnableViewState="False" ... %>
    Per application (in web.config) : <Pages EnableViewState="false" ... />

    You can also disable it for individual controls.

    Doing that will reduce viewstate to a very small size.

    If you want to disable it completely ( remove it ), see Natty Gur's sample code :

    http://weblogs.asp.net/ngur/archive/2004/03/08/85876.aspx
     
    Juan T. Llibre, Mar 6, 2007
    #4
  5. reju

    Mark Rae Guest

    Mark Rae, Mar 6, 2007
    #5
  6. reju

    reju Guest

    Hi Juan,
    when I override the SavePageStateToPersistenceMedium method my submitt
    buttons are not working,
    I can't navigate to next page
    Reju
     
    reju, Mar 6, 2007
    #6
  7. reju

    reju Guest

    Hi Juan,
    when I override the SavePageStateToPersistenceMedium method my submit
    buttons are not working,
    I can't navigate to next page
    Reju
     
    reju, Mar 6, 2007
    #7
  8. You have to weigh the pros and cons of disabling Viewstate
    and determine whether disabling it is a good policy for you.





    Hi Juan,
    when I override the SavePageStateToPersistenceMedium method my submit
    buttons are not working,
    I can't navigate to next page
    Reju
     
    Juan T. Llibre, Mar 6, 2007
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.