About ViewState

xiaoxiao2021-03-06  51

Use a lot of viewState to save status when writing controls, for example:

Public String CurrentPageIndex {

Get {

Return ViewState ["CurrentPageIndex"]. TOSTRING ();

}

SET {

ViewState ["CurrentPageIndex"] = Value;

}

}

Many tutorials use the above ways, there will be errors when practical applications, and the specifically when using this control, the property will report an error: not applying the object to the instance!

Change this.

Public String CurrentPageIndex {

Get {

Object obj = viewstate ["currentpageindex"];

Return (obj == null)? String.empty: obj.tostring ();

}

SET {

ViewState ["CurrentPageIndex"] = Value;

}

}

转载请注明原文地址:https://www.9cbs.com/read-115559.html

New Post(0)