Results 1 to 8 of 8

Thread: Can't seem to disable ViewState

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    Can't seem to disable ViewState

    Seems like no matter what I do, I can't disable ViewState. I have placed the correct directive at both the page level and web.config level, but ViewState keeps showing up in the web page.

    Any help on this would be appreciated.

    Visual Studio 2010

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Can't seem to disable ViewState

    Elaborate on what you mean by "ViewState keeps showing up in the web page"

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    Re: Can't seem to disable ViewState

    If you look at the page source, you still see a hidden field called "__ViewState"...

    Visual Studio 2010

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Can't seem to disable ViewState

    Yes but how does this manifest itself in your page and/or pose a problem?

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    Re: Can't seem to disable ViewState

    Quote Originally Posted by mendhak
    Yes but how does this manifest itself in your page and/or pose a problem?
    It manifests itself in my page because it is in my page. The problem is that I don't want ViewState and don't need it. Isn't it optional?? So why can't I seem to turn it off?

    Visual Studio 2010

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Can't seem to disable ViewState

    The hash value comes up anyways. You need to override a couple methods to disable it almost completely. Place this in your page's codebehind:

    VB Code:
    1. Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
    2.  
    3.  
    4.  
    5.     End Sub
    6.  
    7.     Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
    8.         Return Nothing
    9.  
    10.     End Function
    11.  
    12.     Protected Overrides Function SaveViewState() As Object
    13.  
    14.         Return Nothing
    15.  
    16.     End Function

  7. #7
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: Can't seem to disable ViewState

    Quote Originally Posted by mendhak
    The hash value comes up anyways. You need to override a couple methods to disable it almost completely. Place this in your page's codebehind:

    VB Code:
    1. Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
    2.  
    3.  
    4.  
    5.     End Sub
    6.  
    7.     Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
    8.         Return Nothing
    9.  
    10.     End Function
    11.  
    12.     Protected Overrides Function SaveViewState() As Object
    13.  
    14.         Return Nothing
    15.  
    16.     End Function
    I wanted to say that.... or Page.EnableViewState = false;
    Magiaus

    If I helped give me some points.

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Can't seem to disable ViewState

    I'm assuming he did that already, but I think he had a problem with the small hashstring that shows up in the html source anyways.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width