Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > LoadControl() method throws virtual path error when attempting to load user control from subfolder.

Reply
Thread Tools

LoadControl() method throws virtual path error when attempting to load user control from subfolder.

 
 
Jeremy
Guest
Posts: n/a
 
      06-24-2004
Everything in my app worked fine - then I moved some user controls to a
subfolder named \ControlTemplates that physically exists directly under the
site root.

Then, at runtime when these lines attempts to load a user control from that
subdirectory:
string templateFileName = @"/ControlTemplates/Template01.ascx";
Control templateControl = LoadControl(templateFileName);

The application throws an error with the following message:
The virtual path '/ControlTemplates/Template01.ascx' maps to another
application, which is not allowed.

How can I load user controls that are physically stored in a subfolder under
the site root?

Thanks.


 
Reply With Quote
 
 
 
 
Oleg Ogurok
Guest
Posts: n/a
 
      06-24-2004

Try adding a tilda (~)
string templateFileName = @"~/ControlTemplates/Template01.ascx";

or you can get the root of your app this way:

string templateFileName = Request.ApplicationRoot +
@"/ControlTemplates/Template01.ascx";

-Oleg.


"Jeremy" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Everything in my app worked fine - then I moved some user controls to a
> subfolder named \ControlTemplates that physically exists directly under

the
> site root.
>
> Then, at runtime when these lines attempts to load a user control from

that
> subdirectory:
> string templateFileName = @"/ControlTemplates/Template01.ascx";
> Control templateControl = LoadControl(templateFileName);
>
> The application throws an error with the following message:
> The virtual path '/ControlTemplates/Template01.ascx' maps to

another
> application, which is not allowed.
>
> How can I load user controls that are physically stored in a subfolder

under
> the site root?
>
> Thanks.
>
>



 
Reply With Quote
 
 
 
 
Jeremy
Guest
Posts: n/a
 
      06-24-2004
Thank you - that solved the problem.


"Oleg Ogurok" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Try adding a tilda (~)
> string templateFileName = @"~/ControlTemplates/Template01.ascx";
>
> or you can get the root of your app this way:
>
> string templateFileName = Request.ApplicationRoot +
> @"/ControlTemplates/Template01.ascx";
>
> -Oleg.
>
>
> "Jeremy" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Everything in my app worked fine - then I moved some user controls to a
> > subfolder named \ControlTemplates that physically exists directly under

> the
> > site root.
> >
> > Then, at runtime when these lines attempts to load a user control from

> that
> > subdirectory:
> > string templateFileName = @"/ControlTemplates/Template01.ascx";
> > Control templateControl = LoadControl(templateFileName);
> >
> > The application throws an error with the following message:
> > The virtual path '/ControlTemplates/Template01.ascx' maps to

> another
> > application, which is not allowed.
> >
> > How can I load user controls that are physically stored in a subfolder

> under
> > the site root?
> >
> > Thanks.
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
physical path to virtual path under virtual directory =?Utf-8?B?SmVmZiBCZWVt?= ASP .Net 4 08-01-2007 02:59 PM
calling a method with 'throws IOException' from another method in the same class rleroux@telus.net Java 1 01-28-2007 06:30 AM
'bad' 32 bit drivers attempting to load and itunes Simon Meacham Windows 64bit 2 05-28-2006 12:08 PM
I see no difference in an inheirited non-virtual method and an inheirited virtual method jlopes C++ 7 11-19-2004 07:47 PM
Attempting to uninstall Microsoft Java Virtual Machine (JVM) 'Ole Computer Support 3 02-21-2004 06:46 PM



Advertisments