Monday, October 11, 2004

Persisting a Property value for a Web Control

//This code block shows how to persist a boolean property value in a web control.

[
Bindable(true),
Category("Behaviour"),
DefaultValue(true),
Description("Show Condition")
]
public bool ShowCondition
{
get
{
bool selval;
if( ViewState["ShowCondition"] == null)
{
selval = true;
}
else
{
selval = (bool) ViewState["ShowCondition"];
}
return(selval);
}
set
{
this.ViewState["ShowCondition"] = value;
}
}

No comments: