The reason is That page would be much more search engine friendly and it would render faster in the browser.So i have implemented fuctionality to render the viewstate on bottom of the page .I have overrided the "RenderControl" event in master page.here is the code
Copy this code and paste into master page .run the application .Now you can see _viewstate renders in bottom of the page .
///
/// Code for moving the Viewstate to bottom of the page
///
///
public override void RenderControl(HtmlTextWriter writer)
{
using (System.IO.StringWriter stringWriter = new System.IO.StringWriter())
{
using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
{
base.Render(htmlWriter);
string html = stringWriter.ToString();
int beginPoint = html.IndexOf("<input type=\"hidden\" name=\"__VIEWSTATE\"")
{
int endPoint = html.IndexOf("/>", beginPoint) + 2;
string viewstateInput = html.Substring(beginPoint, endPoint - beginPoint);
html = html.Remove(beginPoint, endPoint - beginPoint);
int formEndStart = html.IndexOf("") - 1;
if (formEndStart >= 0)
{
html = html.Insert(formEndStart, viewstateInput);
}
}
writer.Write(html);
}
}
}
Is there any way to compress the view state ?
ReplyDelete