Setting bit flag enum value in aspx file ?

Discussion in 'ASP .Net' started by Moe Sisko, Jan 2, 2008.

  1. Moe Sisko

    Moe Sisko Guest

    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.
    Moe Sisko, Jan 2, 2008
    #1
    1. Advertising

  2. Moe Sisko

    Flatulus

    Joined:
    Jan 2, 2008
    Messages:
    2
    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;
    	...
    }
    
    Flatulus, Jan 2, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    1,750
    Timothy Bendfelt
    Jan 19, 2007
  2. mrhicks
    Replies:
    3
    Views:
    340
    James Dow Allen
    Sep 1, 2004
  3. Replies:
    9
    Views:
    968
    Juha Nieminen
    Aug 22, 2007
  4. Moe Sisko
    Replies:
    2
    Views:
    213
    Moe Sisko
    Jan 7, 2008
  5. Jeff.M
    Replies:
    6
    Views:
    172
    Lasse Reichstein Nielsen
    May 4, 2009
Loading...

Share This Page