User controls

  • Thread starter Thread starter Murphy
  • Start date Start date
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
 
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 :)
 
Back
Top