Completely disable viewstate

S

sri_san

Hello,
I have a aspx page in which I would like to eliminate all of
the hidden variables as this page would be imported to an email client
and the hidden controls are usually rendered in the mail client. The
asp.net form does have the form input hidden control inspite the
viewstate is disabled at the page level. Isnt there a way to eliminate
it? And, as per my understanding, it just cant be eliminated. Now, I
was trying to parse the page treating it as a XML doc and remove the
hidden control. The problem there would be - there is no guarantee that
the XML document is well formed as the page contains formatted text and
might miss some of the closing tags. Is there a better way to get rid
of the input hidden form level viewstate ( ID = "__VIEWSTATE") ?

Thanks,
Sam.
 
B

bruce barker

as you don't care about postback just add to your page:


// override standard viewstate handler with do nothing
protected override void SavePageStateToPersistenceMedium(Object state)
{
}


-- bruce (sqlwork.com)
 
R

Rad [Visual C# MVP]

Hello,
I have a aspx page in which I would like to eliminate all of
the hidden variables as this page would be imported to an email client
and the hidden controls are usually rendered in the mail client. The
asp.net form does have the form input hidden control inspite the
viewstate is disabled at the page level. Isnt there a way to eliminate
it? And, as per my understanding, it just cant be eliminated. Now, I
was trying to parse the page treating it as a XML doc and remove the
hidden control. The problem there would be - there is no guarantee that
the XML document is well formed as the page contains formatted text and
might miss some of the closing tags. Is there a better way to get rid
of the input hidden form level viewstate ( ID = "__VIEWSTATE") ?

Thanks,
Sam.

You'll probably run into problems trying to get a XML compliant document
from a HTML page unless you go out of your way to make the page compliant.

If you really need to eliminate the viewstate you could use a regular
expression to find and remove it.
 
S

sri_san

Thanks for the reply. I would appreciate any pointers in specific the
use of regular expressions to remove it from the page.

P.S: Overriding 'SavePageStateToPersistenceMedium' clears the viewstate
completely but the hidden control is still rendered on the page.

Thanks again,
Sam.
 
M

Mark Rae

as you don't care about postback just add to your page:

// override standard viewstate handler with do nothing
protected override void SavePageStateToPersistenceMedium(Object state)
{
}

Yes, but that still leaves the hidden controls which the OP wants removed,
for some reason...
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top