How do I update references to user controls after putting ascx
and aspx
files into different folders?
I'm not used to working with ASP.NET Web Forms projects, but I inherited this one. When I first received this Project, every file was directly under the root; no folders whatsoever. I've started putting files into folders and updating the paths.
When I try to load a user control, however, I get this error:
Cannot use a leading .. to exit above the top directory.
My user control is located at:
myProject\controls\Widget.asxc
My page is located at:
myProject\Pages\Activity\AST_Page.aspx
Markup from AST_Page.aspx
:
<%@ Register TagPrefix="tf" TagName="Cost" Src="..\..\controls\Widget.ascx" %>
My understanding is:
AST_Page.aspx
, the current path is myProject\\Pages\\Activity\\
...\\..\\
should put me at myProject\\
...\\..\\controls\\Widget.ascx
actually points to myProject\\controls\\Widget.asxc
.myProject\\
. If I change ..\\..\\controls\\Widget.ascx
to ..\\controls\\Widget.ascx
, I get a different error about not finding the file, which is expected as Widget.ascx
is not under myProject\\Pages\\controls\\
.
There was a second issue on the page. I had "~/../../" in a src attribute; likely due to an aggressive find and replace.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.