How to get the type of a control

Discussion in 'ASP .Net' started by shapper, Oct 31, 2007.

  1. shapper

    shapper Guest

    Hello,

    I created 3 custom controls: A, B and C.
    Given a control how can I get its type and check if it is of type A, B
    or C?

    Thanks,
    Miguel
     
    shapper, Oct 31, 2007
    #1
    1. Advertising

  2. ..GetType()????

    --
    Regards,
    Alvin Bruney
    ------------------------------------------------------
    Shameless Author Plug
    OWC Black Book 2nd Edition
    Exclusively on www.lulu.com/owc
    $19.99


    "shapper" <> wrote in message
    news:...
    > Hello,
    >
    > I created 3 custom controls: A, B and C.
    > Given a control how can I get its type and check if it is of type A, B
    > or C?
    >
    > Thanks,
    > Miguel
    >
     
    Alvin Bruney [MVP], Oct 31, 2007
    #2
    1. Advertising

  3. shapper

    Scott M. Guest

    If A.GetType() = B.GetType() Then.....

    ....or...

    If GetType(A) = GetType(B) Then....

    ....or....

    Select Case A.GetType.Name
    Case B.GetType.Name
    ' Do something

    Case C.GetType.Name
    ' Do something

    End Select

    "shapper" <> wrote in message
    news:...
    > Hello,
    >
    > I created 3 custom controls: A, B and C.
    > Given a control how can I get its type and check if it is of type A, B
    > or C?
    >
    > Thanks,
    > Miguel
    >
     
    Scott M., Nov 1, 2007
    #3
  4. maybe you could use the "IS" keyword/operator?


    On Wed, 31 Oct 2007 20:12:56 -0400, "Scott M." <>
    wrote:

    >If A.GetType() = B.GetType() Then.....
    >
    >...or...
    >
    >If GetType(A) = GetType(B) Then....
    >
    >...or....
    >
    >Select Case A.GetType.Name
    > Case B.GetType.Name
    > ' Do something
    >
    > Case C.GetType.Name
    > ' Do something
    >
    >End Select
    >
    >"shapper" <> wrote in message
    >news:...
    >> Hello,
    >>
    >> I created 3 custom controls: A, B and C.
    >> Given a control how can I get its type and check if it is of type A, B
    >> or C?
    >>
    >> Thanks,
    >> Miguel
    >>

    >
     
    John MJ Gorter, Nov 1, 2007
    #4
  5. shapper

    Scott M. Guest

    Yep, I realized that just as I was looking at my post. Replace "=" with
    "Is" when checking a type against another type.


    "John MJ Gorter" <> wrote in message
    news:...
    > maybe you could use the "IS" keyword/operator?
    >
    >
    > On Wed, 31 Oct 2007 20:12:56 -0400, "Scott M." <>
    > wrote:
    >
    >>If A.GetType() = B.GetType() Then.....
    >>
    >>...or...
    >>
    >>If GetType(A) = GetType(B) Then....
    >>
    >>...or....
    >>
    >>Select Case A.GetType.Name
    >> Case B.GetType.Name
    >> ' Do something
    >>
    >> Case C.GetType.Name
    >> ' Do something
    >>
    >>End Select
    >>
    >>"shapper" <> wrote in message
    >>news:...
    >>> Hello,
    >>>
    >>> I created 3 custom controls: A, B and C.
    >>> Given a control how can I get its type and check if it is of type A, B
    >>> or C?
    >>>
    >>> Thanks,
    >>> Miguel
    >>>

    >>
     
    Scott M., Nov 1, 2007
    #5
    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. heyo
    Replies:
    3
    Views:
    948
    Dan Pop
    Apr 1, 2004
  2. pete
    Replies:
    4
    Views:
    821
    Dan Pop
    Apr 2, 2004
  3. Yevgen Muntyan

    #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type)))

    Yevgen Muntyan, Feb 9, 2007, in forum: C Programming
    Replies:
    10
    Views:
    931
    Yevgen Muntyan
    Feb 13, 2007
  4. Diego Martins
    Replies:
    5
    Views:
    499
    Diego Martins
    Sep 5, 2006
  5. kj
    Replies:
    5
    Views:
    425
Loading...

Share This Page