User controls

M

Murphy

I have created a user control for the page header and page footer, the
footer control contains links to Terms, Privacy etc. As my site will have
pages in sub directories I would like to use these user controls in the sub
directories to.

The problem I have encountered is that when the control is used in a sub
directory it references links in that sub directory as opposed to where the
files are located, in the root directory.

For example default.aspx may include footer.ascx that references
privacy.aspx so the link in the browser is localhost/privacy.aspx however
when footer is used in default.aspx in the "business' subdirectory the link
to privacy appears as localhost/business/privacy.aspx. If possible I would
prefer to create a footer, header etc user control for ever directory as
this will be a maintenance nightmare and defeat the purpose of creating code
in reusable modules.

Any ideas would be greatly appreciated.

Murphy
 
T

tomledk

If you prefix your link with ~ it will start at the webroot and thereby
result in the correct path to your file.

Exampel: "~/privacy.aspx".

tomledk :)
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top