TemplateControl.LoadControl from a vb class?

Discussion in 'ASP .Net' started by MattB, Feb 2, 2006.

  1. MattB

    MattB Guest

    I'm making a reusable class to load and populate user controls based on
    database values. I had the basic code working from codebehind, and now
    I'm moving it to a reusable class.

    Once in the class, Intellisense doesn't like:

    LoadControl(myUserControlPath)

    So I looked up that method and saw it was a member of TemplateControl,
    and tried this:

    TemplateControl.LoadControl(myUserControlPath)

    And Intellisense says it requires an object reference, so I try this:

    Dim TC as TemplateControl
    TC.LoadControl(myUserControlPath)

    It gets by Intellisense, but gives the runtime error: Object reference
    not set to an instance of an object on the line with TC.LoadControl, and
    I can't instantiate a new instance of the TemplateControl class either.

    Can someone tell me if/how I can make this work from my class so I don't
    have to duplicate the code on multiple pages? Thanks!

    Matt
    MattB, Feb 2, 2006
    #1
    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. =?Utf-8?B?Sm9l?=
    Replies:
    1
    Views:
    3,856
    =?Utf-8?B?Sm9l?=
    Dec 27, 2005
  2. DC
    Replies:
    0
    Views:
    692
  3. Laurahn
    Replies:
    1
    Views:
    809
    Steven Cheng[MSFT]
    Jun 11, 2007
  4. Ron Vecchi

    TemplateControl??

    Ron Vecchi, Apr 14, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    192
  5. Larry Neylon

    Use a [WebMethod] in a TemplateControl

    Larry Neylon, Sep 22, 2009, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    762
    Larry Neylon
    Sep 22, 2009
Loading...

Share This Page