Thanks very much for the help Michael.
If anyone else is interested here are the C# implementations
To Calculate Viewstate size :
protected override void SavePageStateTo PersistenceMedi um(object viewState)
{
base.SavePageSt ateToPersistenc eMedium(viewSta te);
LosFormatter format = new LosFormatter();
StringWriter writer = new StringWriter();
format.Serializ e(writer, viewState);
int viewStateLength = writer.ToString ().Length;
To Calculate page size :
protected override void Render(HtmlText Writer writer)
{
StringWriter customWriter = new StringWriter();
HtmlTextWriter localWriter = new HtmlTextWriter( customWriter);
base.Render(loc alWriter);
int pageLength = customWriter.To String().Length ;
writer.Write(cu stomWriter.ToSt ring());
"Michael" <raterus@localh ost> wrote in message
news:#5******** ******@TK2MSFTN GP09.phx.gbl...
You can determine page size by doing this in the Render event (Sorry this
example is in vb.net, but it should be similar in C#)
Dim sw As New System.IO.Strin gWriter
Dim localWriter As New HtmlTextWriter( sw)
MyBase.Render(l ocalWriter)
Dim output As String = sw.ToString()
Dim size As Long
size = output.Length()
writer.Write(ou tput)
I'm not quite as sure about viewstate, but this page may help you
http://www.aspalliance.com/articleVi...x?aId=135&pId=
"NewsAccoun t" <no****@nospam. com> wrote in message
news:uM******** ******@TK2MSFTN GP11.phx.gbl... Hi
I'm trying to find a way to programmaticall y measure the size of the
page sent down to the browser, can't seem to measure the length of what gets
written to the HTML TextWriter in
protected override void Render(HtmlText Writer writer)
{
Also, I want to find the size of the viewstate when rendering the page.
I've seen a way to get this when posting back, however, I would like to do
this at render time so that I can neatly log this information .
Any ideas ?
Many thanks
Guy