Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With ViewState Please

Status
Not open for further replies.

Schimsky

Programmer
Oct 4, 2003
23
0
0
US
Hi,

I have an asp.net page with the page directive being...

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Survey2.aspx.vb" Inherits="WebApplication1.Survey2" enableViewState="False"%>

Notice I have enableViewState = False. When I run the page and look at the Source, There is a TON of info in the viewstate field. Why is this?

Thanks For Any Help.

Steve
 
Hmmm - to be honest I didn't believe you until I tried it for myself. However, I have checked it and proved (at least to myself) that there is less in the viewstate when the enableViewState property is turned off compared to when it is on. But I needed to close down the browser to see the difference.

I don't know why the viewstate hidden control is there at all when the page does not have the property set, so I came up with the routine below to decode what is in the viewstate. Maybe I have got it slightly wrong, but it does not help much.

Hope this helps
Mark
Code:
        'WinForm routine to convert from base 64 to a normal string (I think this should decode the contents of the viewstate)
        Dim s As String = InputBox("Enter")
        Dim b() As Byte = System.Convert.FromBase64String(s)
        Dim sm As New System.IO.MemoryStream(b)
        Dim sr As New System.IO.StreamReader(sm, System.Text.Encoding.ASCII)
        Dim s2 As String = sr.ReadToEnd
        MessageBox.Show(s2)

Mark [openup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top