I have a site that features some pages which do not require any post-back functionality. They simply display static HTML and don\'t even have any associated code. H
You could override Render and strip it out with a Regex.
Sample as requested. (NB: Overhead of doing this would almost certainly be greater than any possible benefit though!)
[edit: this function was also useful for stripping all hidden input boxes for using the HTML output as a word doc by changing the MIMEType and file extension]
protected override void Render(HtmlTextWriter output)
{
StringWriter stringWriter = new StringWriter();
HtmlTextWriter textWriter = new HtmlTextWriter(stringWriter);
base.Render(textWriter);
textWriter.Close();
string strOutput = stringWriter.GetStringBuilder().ToString();
strOutput = Regex.Replace(strOutput, "<input[^>]*id=\"__VIEWSTATE\"[^>]*>", "", RegexOptions.Singleline);
output.Write(strOutput);
}
In the <% @page... directive at the top of the page, add EnableViewState="False". That will prevent the ViewState for that particular page.