Hello, I have created a custom Server control that processes some data, stores that data to ViewState, and then renders itself from that data. I am using the debugger and can physically see the data getting set to ViewState:
public string RawData
{
get
{
string result = null;
if (ViewState["RawData"] != null)
{
result = ViewState["RawData"].ToString();
}
return result;
}
set
{
ViewState["RawData"] = value;
}
}
However, after postback the ViewState value is not persisted, and it is null. Why is this happening? Where can I look to try to troubleshoot? I can tell that the ViewState hidden field length has increased since using this approach.
Thanks in advance!
EDIT: Here is my Render method to see where I am setting the ViewState:
protected override void Render(HtmlTextWriter writer)
{
if (this.RawData == null)
{
StringBuilder content = new StringBuilder();
content.Append(this.BuildHeader());
content.Append(this.BuildLevelsMarkup());
content.Append(this.BuildFooter());
this.RawData = content.ToString();
}
writer.Write(this.RawData);
}