I have a class "Wepart A" and a class "Webpart B" which have some similiarities. So I introduced a BaseWebpart from which A and B inherit.
I want to share 2 properties (SortColumn and SortDirection) which are stored in viewstate:
protected string SortRow
{
get
{
object o = ViewState["SortRow"];
if (o == null)
{
return String.Empty;
}
return (string)o;
}
set
{
if (value == SortRow)
{
SortAscending = !SortAscending;
}
ViewState["SortRow"] = value;
}
}
protected bool SortAscending
{
get
{
object o = ViewState["SortAscending"];
if (o == null)
{
return true;
}
return (bool)o;
}
set
{
ViewState["SortAscending"] = value;
}
}
and put them to the BaseWebpart. Can I access them in Webpart A and B without problems? I guess the ViewState-Keys could be a problem...any suggestions?