473,508 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Joe
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.Attribu tes("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,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
Dec 27 '05 #1
1 2304
Joe
Got it. Thank you anyway.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Joe" wrote:
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.Attribu tes("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,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Dec 27 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1833
by: George Durzi | last post by:
I have a C# in my web application called BasePage. It inherits from System.Web.UI.Page. I'm using page inheritance in my web app so all my pages have an identical look and feel by inheriting from...
5
1812
by: ozie | last post by:
Hi , I am new to ASP.NET. I was reading about Page class in one of the ASP.NET books and am confused with the way the Page class is actually implemented.What is didnt understand in when is this...
0
901
by: ElanKathir | last post by:
Hi All ! Here by attached two type's of Code, One -> ASP Controls Tag Code Another -> Server side Script of the page. The Server Side Script have Two Class
3
3001
by: Robert Walter | last post by:
I want to user the Page method LoadControl inside the Global.asax.cs but when I instantiate a page and try it I get the following error... System.NullReferenceException: Object reference not set...
4
7826
by: Christopher | last post by:
I am trying to load a UserControl which inherits from one of our customer classes which in turn inherits from UserControl. We use Page.LoadControl() from within our ASP.NET pages to load these...
8
5226
by: Sam Kuehn | last post by:
How do I accomplish the fallowing (is it even possible). Say I write a UserControl "MyControl.ascx". Now I use LoadControl("MyControl.ascx"). But I really want MyControl to require parameters in...
6
3550
by: mister.mwa | last post by:
Hello, I have the following problem: I have a class Foo, and a class Bar. I want Foo to inherit from Bar, but i want to put them in separate files Foo.vb and Bar.vb. Then i will use the Foo...
5
3140
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
0
3765
by: Carl Wright | last post by:
Hi I'm having this major issue loading a usercontrol at runtime using the overload on Loadcontrol(type,object). Here's the code in the aspx code-behind file Dim myControl As New Control Dim...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.