User-707554951 posted
Hi vinodkpasi,
Which is the last event to modify ViewState?
ASP.net page lifecycle the order goes (this is the short version):
Preinit -> Init -> Load Viewstate -> Page Load ->
Events -> PreRender -> Save Viewstate -> Render -> Unload
Places where changes to viewstate are persisted in Bold. As a result the last chance you have to modify viewstate and have it persisted is PreRender (technically you could handle SaveViewState and that would be your last chance to modify viewstate and have
it saved).
MSDN:
http://msdn.microsoft.com/en-us/library/ms178472.aspx#additional_page_life_cycle_considerations
Which is the last event to modify page output?
Render event.
protected override void Render(HtmlTextWriter writer)
{
StringBuilder htmlString = new StringBuilder(); // this will hold the string
StringWriter stringWriter = new StringWriter(htmlString);
HtmlTextWriter tmpWriter = new HtmlTextWriter(stringWriter);
Page.Render(tmpWriter);
writer.Flush();
writer.Write(DoReplaceLogic(htmlString.ToString()););
}
Best regards
Cathy