I am developing a custom dataBound control. I am lacking,
when the visible property of the custom dataBound control set as false in pageLoad means, in postback the control visibility not maintain.
I have override the saveViewState method, in that i have update the some of the properties of custom data bound control and stored that properties in object.
Same object , retried in LoadViewState method, i unable to get the visible property.
My requirements: I need to get the visible state of custom control in saveViewState method, but saveViewSate meth
protected override object SaveViewState(){
}
By, generally saveViewState method did not accept any arguments, then how come i get the visible state of the control.
Yes, we can able to get the default properties of custom controls in SaveViewSate method as follows
protected override object SaveViewState(){
object[] myState = new object[2];
myState[0] = base.SaveViewState(); // this will store the default properties status such as visible,
return myState;
}
protected override void LoadViewState(object state)
{
object[] myState = null;
if (state != null)
{
myState = (object[])state;
}
base.LoadViewState(myState[0]);
}
In LoadViewState, you can able to restore the state as above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.