I need to check whether an event is fired from the master page or not. For that i kept a count in the viewstate . This is throwing exception on page load. I’m just calling the below line in a pageload
Int32 count = Int32.Parse(this.ViewState["Count"].ToString());
Please help.
This will throw an exception in a few cases.
ViewState["Count"]will return null and the.ToString()call will throw aNullReferenceException.FormatException.Things to try:
Your code can be improved as follows: