Possible to set a UserControl's bitwise Enum value in aspx file ?

Discussion in 'ASP .Net Web Controls' started by Moe Sisko, Jan 3, 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 ?


    Thanks.
     
    Moe Sisko, Jan 3, 2008
    #1
    1. Advertising

  2. Moe Sisko

    Louis Somers Guest

    Re: Possible to set a UserControl's bitwise Enum value in aspx file?

    Moe Sisko schreef:
    > 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 ?
    >
    >
    > Thanks.
    >


    In ASPX files, use comma's instead of Pipe characters.

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

    Cheers,
    Louis
     
    Louis Somers, Jan 7, 2008
    #2
    1. Advertising

  3. Moe Sisko

    Moe Sisko Guest

    Louis,

    That's exactly what I needed, thanks a lot !


    "Louis Somers" <> wrote in message
    news:47824908$0$20935$4all.nl...
    >
    > In ASPX files, use comma's instead of Pipe characters.
    >
    > <uc:MyControl runat="server" ID="ucMyControl"
    > AllowedOptions="OptionA,OptionC" />
    >
     
    Moe Sisko, Jan 7, 2008
    #3
    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. -

    enum within an enum

    -, Jun 12, 2005, in forum: Java
    Replies:
    6
    Views:
    565
  2. Jerminia
    Replies:
    3
    Views:
    641
    Roedy Green
    Oct 7, 2005
  3. Ernst Murnleitner

    How to enum an enum?

    Ernst Murnleitner, Nov 12, 2003, in forum: C++
    Replies:
    5
    Views:
    485
    Rolf Magnus
    Nov 13, 2003
  4. mrhicks
    Replies:
    2
    Views:
    439
    Dave Thompson
    Jun 10, 2004
  5. Moe Sisko
    Replies:
    1
    Views:
    738
    Flatulus
    Jan 2, 2008
Loading...

Share This Page