So, the thought occurred to me that I should be able to store ViewState in Session. Below is the implementation in my Default.aspx
private string ViewStateName = "ViewStateName";
protected override object LoadPageStateFromPersistenceMedium()
{
string m_viewState;
LosFormatter m_formatter;
object viewStateBag;
m_viewState = Session[ViewStateName] == null ? null : (string )Session[ViewStateName];
m_formatter = new LosFormatter();
try
{
viewStateBag = m_formatter.Deserialize(m_viewState);
}
catch (Exception e)
{
throw new ApplicationException("The View State is invalid or corrupted", e);
}
return viewStateBag;
}
protected override void SavePageStateToPersistenceMedium(object viewStateBag)
{
// string file = GetFileName();
StringBuilder sb =
new StringBuilder();StringWriter sw =
new StringWriter(sb);LosFormatter formatter =
new LosFormatter();formatter.Serialize(sw, viewStateBag);
sw.Close();
Session[ViewStateName] = sb.ToString();
}
No comments:
Post a Comment