Enum Property

B

brandonjack007

I have an enum property in web control. I can set it to One, Five,
Fifteen. It always returns "One" at runtime. Any suggestion.

public enum Interval
{
One,
Five,
Fifteen
}

[Bindable(true),
Category("Appearance"),
Description("Sets Minute Interval. Permissible values are One,
Five, Fifteen"),
DefaultValue(""),

DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.Attribute)]
public virtual Interval MinuteInterval
{
get
{
object result = this.ViewState["MinuteInterval"];
if (result != null)
return (Interval)result;
else
return Interval.One;
}
set
{
ViewState["MinuteInterval"] = value;
}
}
 
S

Scott M.

It looks to me like ViewState["MinuteInterval"] is not getting a value in
the first place, causing you to always return "one". Why not try using your
enum with a simple property first and then move on to ViewState values?
 
M

marss

[Bindable(true),
Category("Appearance"),
Description("Sets Minute Interval. Permissible values are One,
Five, Fifteen"),
DefaultValue(""),

DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.Attribute)]
public virtual Interval MinuteInterval
{

Remove
DesignerSerializationVisibility(DesignerSerializationVisibility.Content).
Default value for this attribute is Visible - it has to used set in
your case.

Regards,
Mykola
http://marss.co.ua
 
B

brandonjack007

Removing
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
fix the isssue.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top