LoadControl in a class that inherits System.Web.UI.Page

G

Guest

Hello All,

I have a class that inherits from System.Web.UI.Page. In it I call the
Page.LoadControl. I am having trouble with the virtual path that the
LoadControl method accepts as its parameter.

I have the following code in a method call:

Dim uControl As CustomAddresses =
CType(Page.LoadControl("../UserControls/CustomAddresses.ascx"),
CustomAddresses)
uControl.PopulateAddressBoxes(NodeToRender.Attributes("value").Value.Trim)
Return uControl

I get the following error when I run this code:

"Cannot use a leading .. to exit above the top directory"

The virtual path from this class to the UserConrol is correct. I suspect I
am geting the error because I am using Page.LoadControl. How do I reference
a control from a class that inherits the Page class? What would the virtual
path be?

TIA,
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top