473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Absolute reference

Hi

How can I set an absolute reference to site root in a page link so the
referenced page is always accessed from the site root folder?

Thanks

Regards
Feb 18 '07 #1
5 1182
John wrote:
Hi

How can I set an absolute reference to site root in a page link so the
referenced page is always accessed from the site root folder?

Thanks

Regards

You can use the "~" root operator:

<a href="~/Default.aspx" runat="server">Home</a>

--
Göran Andersson
_____
http://www.guffa.com
Feb 18 '07 #2
Use ASP.NET server controls (e.g, Hyperlink). You can set the NavigatUrl to
something like "~/myfolder/myresource.aspx". The tilde (~) always will
resolve relative to to root of the web site.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"John" wrote:
Hi

How can I set an absolute reference to site root in a page link so the
referenced page is always accessed from the site root folder?

Thanks

Regards
Feb 18 '07 #3
Hi John,

In addition to Peter's and Goran's replies, every descandant that derives
from Control class has ResolveUrl() that converts a URL into one that is
usable on the requesting client.

--
Milosz
"John" wrote:
Hi

How can I set an absolute reference to site root in a page link so the
referenced page is always accessed from the site root folder?

Thanks

Regards
Feb 18 '07 #4
Hi

I have used ~ but it instead of http://localhost/staff_news.asp it comes out
as http://localhost/events/~/staff_news.asp i.e. ~ is not being resolved
into root folder. What am I doing wrong?

Thanks

Regards

"Göran Andersson" <gu***@guffa.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
John wrote:
>Hi

How can I set an absolute reference to site root in a page link so the
referenced page is always accessed from the site root folder?

Thanks

Regards

You can use the "~" root operator:

<a href="~/Default.aspx" runat="server">Home</a>

--
Göran Andersson
_____
http://www.guffa.com

Feb 19 '07 #5
The problem is that it's not resolved at all. You probably forgot
runat="server" to turn the tag into a server control.

John wrote:
Hi

I have used ~ but it instead of http://localhost/staff_news.asp it comes out
as http://localhost/events/~/staff_news.asp i.e. ~ is not being resolved
into root folder. What am I doing wrong?

Thanks

Regards

"Göran Andersson" <gu***@guffa.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>John wrote:
>>Hi

How can I set an absolute reference to site root in a page link so the
referenced page is always accessed from the site root folder?

Thanks

Regards
You can use the "~" root operator:

<a href="~/Default.aspx" runat="server">Home</a>

--
Göran Andersson
_____
http://www.guffa.com


--
Göran Andersson
_____
http://www.guffa.com
Feb 19 '07 #6

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

Similar topics

3
by: Peter Taurins | last post by:
Hi there. I have an included file (header.php) that contanis a reference to a graphic. If I stay at the root level, then I can control the relative path of the image. eg. images/imagename.jpg ...
15
by: Nick K. | last post by:
I recently began maintenance work on a production web server that is located in the root directory of a web server. I moved this into a sub web on my local web server in order to do work on it. I...
4
by: Peter Pfannenschmid | last post by:
Hello experts, I would be very grateful if you would have a look at the following URL: http://www.omeganet.de/test.html The html file and the associated style have been validated...
4
by: Rob | last post by:
I have a web project that has multiple directories. Some of the files in different directories use the same include files. The problem is that these include files also reference an image folder. ...
2
by: Joachim Bauer | last post by:
I'm using the code below to display a menu that opens when the mouse goes over the main menu item (try it in your browser to understand the behaviour). It uses "position:absolute" and a switch...
24
by: Wim Roffal | last post by:
I am trying to create a menu system. The mainmenu is a table <table><tr><td>menu1</td><td>menu2</td></tr></table> No I try insert the submenu so that it becomes relative to the main menu...
4
by: Vitali Gontsharuk | last post by:
Hallo! When using the XPATH document() function to load a new XML document, we are coming across problems, because XALAN seems to have problems with absolute paths. XALAN always assumes that the...
14
by: japin0 | last post by:
Hi, I am a absolute beginner in ASP ..I do have a bit of exposure to .VBS and other scripting languages. I need your guidance, where do I start? I had been to MS website Quick start guide but it...
6
by: Jon Slaughter | last post by:
do I have to prefix every absolute path with document root to get it to work? For some reason I thought that prefixing a path with '/' or './' with make it absolute w.r.t to document root but I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
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...

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.