In Master.cs
:
public string sortOrder
{
get
{
if (ViewState["sortOrder"].ToString() == "Desc")
{
ViewState["sortOrder"] = "Asc";
}
else
{
ViewState["sortOrder"] = "Desc";
}
return ViewState["sortOrder"].ToString();
}
set
{
ViewState["sortOrder"] = value;
}
}
I am calling it from a content page:
ViewState["sortOrder"] = "Asc";
PD (e.SortExpression, Master.sortOrder, false);
When executing the function, I get the following error in this line
if (ViewState["sortOrder"].ToString() == "Desc"): Object reference not set to an instance of an object.
The sortOrder
function worked fine when it was also in the content page. I am trying to move all my re-usable code to Master.cs
file.
How can I modify the function so it works as it was in the content page.