Enumerated type in a custom control tag

R

Rex the Strange

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:customcontrol runat='server' id='mycontrol' customvalue='<
%=myenum.value1%>' />

Thanks,

rts
 
R

Rex the Strange

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:customcontrol runat='server' id='mycontrol' customvalue='<
%=myenum.value1%>' />

Thanks,

rts

Never mind. I figured it out. Use:

<my:customcontrol 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='local.library' %>

I hope that helps someone.

rex
 
R

Rex the Strange

Never mind. I figured it out. Use:

<my:customcontrol 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='local.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?
 
R

Rex the Strange

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:DateTextBox ... Type="All" ... />

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

Hello Rex,





- 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/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.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.
 

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