cast in VB.Net

Discussion in 'ASP .Net' started by =?Utf-8?B?QXJuZQ==?=, Aug 1, 2007.

  1. Dim uc As UserControl
    uc = LoadControl("\usercontrol\topheader.ascx")
    Dim top As TopHeader
    How do I convert uc to datatype TopHeader?
    In C# I would do a cast. I have forgot how to do a cast in VB.Net
    --
    Certified Geek
     
    =?Utf-8?B?QXJuZQ==?=, Aug 1, 2007
    #1
    1. Advertisements

  2. Mark Rae [MVP], Aug 1, 2007
    #2
    1. Advertisements

  3. Hi,
    try this code:
    dim r as topheader= ctype(Page.LoadControl("\usercontrol\topheader.ascx"),
    topheader)
    Where topheader is the name of usercontrol class
    --
    Hope this helps.
    Thanks and Regards.
    Manish Bafna.
    MCP and MCTS.



    "Arne" wrote:

    > Dim uc As UserControl
    > uc = LoadControl("\usercontrol\topheader.ascx")
    > Dim top As TopHeader
    > How do I convert uc to datatype TopHeader?
    > In C# I would do a cast. I have forgot how to do a cast in VB.Net
    > --
    > Certified Geek
     
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Aug 2, 2007
    #3
    1. Advertisements

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. BestNews

    how to cast system.intptr to struct

    BestNews, Sep 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    4,986
    BestNews
    Sep 3, 2003
  2. Ajit
    Replies:
    1
    Views:
    3,956
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
  3. Robin

    date cast error in asp.net page

    Robin, Aug 20, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,942
    Robin
    Aug 23, 2004
  4. =?Utf-8?B?TWlrZQ==?=
    Replies:
    1
    Views:
    712
    Alvin Bruney [MVP - ASP.NET]
    Apr 27, 2005
  5. =?Utf-8?B?YW1qYWQ=?=

    urgent asp.net invalid cast error

    =?Utf-8?B?YW1qYWQ=?=, Jun 7, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    603
    Winista
    Jun 7, 2006
  6. MSG

    to cast or not to cast malloc ?

    MSG, Feb 6, 2004, in forum: C Programming
    Replies:
    38
    Views:
    1,436
    Dan Pop
    Feb 10, 2004
  7. EvilRix
    Replies:
    8
    Views:
    911
    Martin Dickopp
    Feb 14, 2004
  8. Pavel
    Replies:
    7
    Views:
    800
    Pavel
    Sep 19, 2010
Loading...