TemplateControl.LoadControl from a vb class?

M

MattB

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
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top