I have one XML document that I want to save to ViewState, so in each column I no longer need to load it from its physical path. I also do not want to store it in SessionState.
when I tried to write it to ViewState, I get an error message:
Exception Details: System.Runtime.Serialization.SerializationException: Type 'System.Xml.XmlDocument' in Assembly 'System.Xml, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089' is not marked as serializable.
My property looks something like this:
private XmlDocument MyDocument {
get
{
object viwObj = ViewState["MyDocument"];
if (viwObj != null)
return (XmlDocument)viwObj;
XmlDocument xmlDoc = GetMyDocument();
ViewState["MyDocument"] = xmlDoc;
return xmlDoc;
}
}
How can I make an XML document serializable later?
thank