Setting bit flag enum value in aspx file ?

M

Moe Sisko

Using dotnet 2.0. Say I have a user control like the following :

public partial class Controls_MyControl : System.Web.UI.UserControl
{
[Flags]
public enum SomeBitFlag
{
OptionA = 0x01,
OptionB = 0x02,
OptionC = 0x04,
}

public SomeBitFlag AllowedOptions { get, set. etc .. }
....
}

Now, on an aspx page, I place an instance of the control, and want to set
"AllowedOptions" :

<uc:MyControl runat="server" ID="ucMyControl" AllowedOptions="OptionA |
OptionC" />

This doesn't work because the aspx page doesn't like the string : "OptionA |
OptionC".
It's easy enough to set the bitflag value in the aspx.cs file, but is there
a way to make this work in the aspx file ?

I realise I can define combo bitflags like :
OptionsA_And_C = OptionA | OptionC in the SomeBitFlag enum def, but I'd
rather not have to do this, as there may be many combinations.

Is what I am trying to do supported in asp.net ?

Thanks.
 
Joined
Jan 2, 2008
Messages
2
Reaction score
0
Im far from being a ASP .NET expert... but couldn't you just set the value of AllowedOptions in the "page load" event handling function?

Something like:

Code:
protected void Page_load()
{
	...
	ucMyControl.AllowedOptions = SomeBitFlag.OptionA | SomeBitFlag.OptionC;
	...
}
 

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,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top