Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LoadControl method

Status
Not open for further replies.

digiduck

Programmer
Apr 4, 2003
95
US
I need to use the LoadContorl method (as in Page.LoadControl) but in the case I'm in I can't use the Page object to call the LoadControl method from? Where else can I call LoadControl from?

Thanks.

Gone looking for myself. Should I arrive before I'm back, keep me here.
 
Okay here's what I came up with, this is being done inside a class not a page so that's why I can't use the page object.

Code:
dim objTC as Web.UI.TemplateControl
dim path as string = "filepath.ascx"

objTC.LoadControl(path)

the last line draws the error "System.NullReferenceException: Object reference not set to an instance of an object."

I understand the error I just don't know how to fix it in this case... I can't declare objTC as a "new" TemplateControl. But i need access to the LoadControl method... Help Please

Gone looking for myself. Should I arrive before I'm back, keep me here.
 
Maybe if your class inherits from a page you could do something like:

this.LoadControl(path);
 
Thank You! Worked perfect :)

Gone looking for myself. Should I arrive before I'm back, keep me here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top