Enumerated type in a custom control tag

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rex the Strange

    #1

    Enumerated type in a custom control tag

    Hello all,

    Can anyone please tell me why I can't do this (and what I can do to
    get the equivalent effect):

    In the code:

    public enum myenum
    value1
    value2
    end enum

    In the aspx page:

    <my:customcontr ol runat='server' id='mycontrol' customvalue='<
    %=myenum.value1 %>' />

    Thanks,

    rts
  • Rex the Strange

    #2
    Re: Enumerated type in a custom control tag

    On Jul 25, 1:20 pm, Rex the Strange <roger.m...@wid getinc.comwrote :
    Hello all,
    >
    Can anyone please tell me why I can't do this (and what I can do to
    get the equivalent effect):
    >
    In the code:
    >
    public enum myenum
      value1
      value2
    end enum
    >
    In the aspx page:
    >
    <my:customcontr ol runat='server' id='mycontrol' customvalue='<
    %=myenum.value1 %>' />
    >
    Thanks,
    >
    rts
    Never mind. I figured it out. Use:

    <my:customcontr ol runat='server' id='mycontrol' customvalue='<% eval
    (myenum.value1) %>' />

    Also, name sure you have an imports tag importing the required
    namespace (in my case):

    <%@ import namespace='loca l.library' %>

    I hope that helps someone.

    rex

    Comment

    • Rex the Strange

      #3
      Re: Enumerated type in a custom control tag

      On Jul 25, 1:30 pm, Rex the Strange <roger.m...@wid getinc.comwrote :
      On Jul 25, 1:20 pm, Rex the Strange <roger.m...@wid getinc.comwrote :
      >
      >
      >
      >
      >
      Hello all,
      >
      Can anyone please tell me why I can't do this (and what I can do to
      get the equivalent effect):
      >
      In the code:
      >
      public enum myenum
        value1
        value2
      end enum
      >
      In the aspx page:
      >
      <my:customcontr ol runat='server' id='mycontrol' customvalue='<
      %=myenum.value1 %>' />
      >
      Thanks,
      >
      rts
      >
      Never mind. I figured it out. Use:
      >
      <my:customcontr ol runat='server' id='mycontrol' customvalue='<% eval
      (myenum.value1) %>' />
      >
      Also, name sure you have an imports tag importing the required
      namespace (in my case):
      >
      <%@ import namespace='loca l.library' %>
      >
      I hope that helps someone.
      >
      rex- Hide quoted text -
      >
      - Show quoted text -
      Nope. That doesn't seem to work. The property is never being set. Any
      ideas anyone?

      Comment

      • The Colorado Kid

        #4
        Re: Enumerated type in a custom control tag

        I've used custom enum values for parameters in custom controls, although
        I reference the name of the enum type directly. If you're setting an attribute
        on the control in page, make sure you have a control property defined as
        being of the particular Enum Type and then reference the type directly.

        I have a textbox control that has several settings, a property called Type
        that expects a custom Type Enum. So in the attributes I have type="All" where
        All is one of the enum values...

        Class DateTextBox
        Enum DateTypeEnum
        All = 1
        Future = 2
        Past = 4
        End Enum

        Public Property Type() As DateTypeEnum
        ...
        End Property

        ....
        End Class

        On page:
        <ocs:DateTextBo x ... Type="All" ... />

        This probably isn't exactly what you're looking for, but I hope it helps...


        Hello Rex,
        On Jul 25, 1:30 pm, Rex the Strange <roger.m...@wid getinc.comwrote :
        >
        >On Jul 25, 1:20 pm, Rex the Strange <roger.m...@wid getinc.comwrote :
        >>
        >>Hello all,
        >>>
        >>Can anyone please tell me why I can't do this (and what I can do to
        >>get the equivalent effect):
        >>>
        >>In the code:
        >>>
        >>public enum myenum
        >>value1
        >>value2
        >>end enum
        >>In the aspx page:
        >>>
        >><my:customcon trol runat='server' id='mycontrol' customvalue='<
        >>%=myenum.valu e1%>' />
        >>>
        >>Thanks,
        >>>
        >>rts
        >>>
        >Never mind. I figured it out. Use:
        >>
        ><my:customcont rol runat='server' id='mycontrol' customvalue='<% eval
        >(myenum.value1 ) %>' />
        >>
        >Also, name sure you have an imports tag importing the required
        >namespace (in my case):
        >>
        ><%@ import namespace='loca l.library' %>
        >>
        >I hope that helps someone.
        >>
        >rex- Hide quoted text -
        >>
        >- Show quoted text -
        >>
        Nope. That doesn't seem to work. The property is never being set. Any
        ideas anyone?
        >

        Comment

        • Rex the Strange

          #5
          Re: Enumerated type in a custom control tag

          On Jul 25, 4:20 pm, The Colorado Kid <tckwrote:
          I've used custom enum values for parameters in custom controls, although
          I reference the name of the enum type directly. If you're setting an attribute
          on the control in page, make sure you have a control property defined as
          being of the particular Enum Type and then reference the type directly.
          >
          I have a textbox control that has several settings, a property called Type
          that expects a custom Type Enum. So in the attributes I have type="All"where
          All is one of the enum values...
          >
          Class DateTextBox
            Enum DateTypeEnum
              All = 1
              Future = 2
              Past = 4
            End Enum
          >
            Public Property Type() As DateTypeEnum
              ...
            End Property
          >
            ....
          End Class
          >
          On page:
          <ocs:DateTextBo x ... Type="All" ... />
          >
          This probably isn't exactly what you're looking for, but I hope it helps....
          >
          Hello Rex,
          >
          >
          >
          On Jul 25, 1:30 pm, Rex the Strange <roger.m...@wid getinc.comwrote :
          >
          On Jul 25, 1:20 pm, Rex the Strange <roger.m...@wid getinc.comwrote :
          >
          >Hello all,
          >
          >Can anyone please tell me why I can't do this (and what I can do to
          >get the equivalent effect):
          >
          >In the code:
          >
          >public enum myenum
          >value1
          >value2
          >end enum
          >In the aspx page:
          >
          ><my:customcont rol runat='server' id='mycontrol' customvalue='<
          >%=myenum.value 1%>' />
          >
          >Thanks,
          >
          >rts
          >
          Never mind. I figured it out. Use:
          >
          <my:customcontr ol runat='server' id='mycontrol' customvalue='<% eval
          (myenum.value1) %>' />
          >
          Also, name sure you have an imports tag importing the required
          namespace (in my case):
          >
          <%@ import namespace='loca l.library' %>
          >
          I hope that helps someone.
          >
          rex- Hide quoted text -
          >
          - Show quoted text -
          >
          Nope. That doesn't seem to work. The property is never being set. Any
          ideas anyone?- Hide quoted text -
          >
          - Show quoted text -
          Hey Kid,

          You have got to be freaking kidding me! I have exactly that
          infrastructure but it never occurred to me to just use the item
          without the enumeration in dot notation (well, it might have if I were
          working in Delphi which doesn't use the dot notation for enumerated
          types). I resorted to using the code builder as demonstrated on this
          page: http://weblogs.asp.net/infinitiesloo...onBuilder.aspx
          which is, really quite cool, but serious overkill for my purposes.

          Your way is much better (and allow me to beat my head against the wall
          for not trying it - it's so bloody obvious).

          rex.

          Comment

          Working...