Write enum outside of your class where do you wanted to display default values i.e. enum values
public enum My_Numbers {
One = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5
}
Include below code where you wanted to displayed on your page i.e. User Control , so you can directly see the values against property Sel_Number = {One,Two,Three,Four,Five}
public My_Numbers Sel_Number
{
get
{
My_Numbers s = (My_Numbers)ViewState["Sel_Number"];
return s;
}
set { ViewState["Sel_Number"] = value; }
}
==========================================================
For More Details Below Complete Code
public enum MyEnum
{
Apple,
Organge
}
[DefaultProperty("Text")]
[ToolboxData("<{0}:TestEnum runat=server></{0}:TestEnum>")]
public class TestEnum : WebControl
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public MyEnum Text
{
get
{
MyEnum s = (MyEnum)ViewState["Text"];
return s;
}
set { ViewState["Text"] = value; }
}
protected override void RenderContents(HtmlTextWriter output)
{
output.Write(Text.ToString());
}
}
public enum My_Numbers {
One = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5
}
Include below code where you wanted to displayed on your page i.e. User Control , so you can directly see the values against property Sel_Number = {One,Two,Three,Four,Five}
public My_Numbers Sel_Number
{
get
{
My_Numbers s = (My_Numbers)ViewState["Sel_Number"];
return s;
}
set { ViewState["Sel_Number"] = value; }
}
==========================================================
For More Details Below Complete Code
public enum MyEnum
{
Apple,
Organge
}
[DefaultProperty("Text")]
[ToolboxData("<{0}:TestEnum runat=server></{0}:TestEnum>")]
public class TestEnum : WebControl
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public MyEnum Text
{
get
{
MyEnum s = (MyEnum)ViewState["Text"];
return s;
}
set { ViewState["Text"] = value; }
}
protected override void RenderContents(HtmlTextWriter output)
{
output.Write(Text.ToString());
}
}
No comments:
Post a Comment