473,385 Members | 2,028 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,385 software developers and data experts.

Get the named anchor from the URL?

In ASPX, how does one get the named anchor from a URL? Its not in any of the ServerVariables.

If a url is: http://www.somerandomsite.com/page.aspx#named_anchor

How do I get the value of the named anchor after the # character?

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Oct 11 '06 #1
6 5541
you don't as the browser does not send the named anchor to the server (it
strips it from the url)

-- bruce (sqlwork.com)
"Greg Collins [Microsoft MVP]" <gcollins_AT_msn_DOT_comwrote in message
news:eZ**************@TK2MSFTNGP04.phx.gbl...
In ASPX, how does one get the named anchor from a URL? Its not in any of the
ServerVariables.

If a url is: http://www.somerandomsite.com/page.aspx#named_anchor

How do I get the value of the named anchor after the # character?

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )

Oct 11 '06 #2
Greg Collins [Microsoft MVP] wrote:
In ASPX, how does one get the named anchor from a URL?
I believe it's System.Uri.Fragment. So it you could get it from the
current page using:

string anchor = Request.Url.Fragment;

http://msdn2.microsoft.com/en-us/net....fragment.aspx

Oct 11 '06 #3
bruce barker (sqlwork.com) wrote:
you don't as the browser does not send the named anchor to the server (it
strips it from the url)
Ahh, yeah. Bruce is right here, it's a client-side thing. The Uri
class has the Fragment property, but you would need some other way of
getting hold of the full url.

Tim

Oct 11 '06 #4
uriAddress.Fragment retrieves the URL's anchor, if it exists.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"bruce barker (sqlwork.com)" <b_*************************@sqlwork.comwrote in message
news:OA**************@TK2MSFTNGP02.phx.gbl...
you don't as the browser does not send the named anchor to the server (it strips it from the url)

-- bruce (sqlwork.com)
"Greg Collins [Microsoft MVP]" <gcollins_AT_msn_DOT_comwrote in message
news:eZ**************@TK2MSFTNGP04.phx.gbl...
In ASPX, how does one get the named anchor from a URL? Its not in any of the ServerVariables.

If a url is: http://www.somerandomsite.com/page.aspx#named_anchor

How do I get the value of the named anchor after the # character?
--
Greg Collins [Microsoft MVP]

Oct 11 '06 #5
re:
Ahh, yeah. Bruce is right here, it's a client-side thing.
I was wrong, too. Mea culpa.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"apathetic" <ap*************@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
bruce barker (sqlwork.com) wrote:
>you don't as the browser does not send the named anchor to the server (it
strips it from the url)

Ahh, yeah. Bruce is right here, it's a client-side thing. The Uri
class has the Fragment property, but you would need some other way of
getting hold of the full url.

Tim

Oct 11 '06 #6
Thanks. I'll check this out.

On a side note, it looks like the named anchor is maintained through a Server.Transfer (even in the case of a custom 404 error page) -- which is pretty cool!

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Oct 12 '06 #7

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

Similar topics

5
by: Peroq | last post by:
Hi all, All of these fail : response.redirect("page.asp?Param=Param#Anchor") response.redirect("page.asp#Anchor?Param=Param") This one works fine : location.href =...
1
by: John | last post by:
HI, I was wondering if it is possible to target a named anchor in a frame when opening a new window with a javascript function? has anyone actualy been able to do this? Thanks in advance for...
4
by: deko | last post by:
I use named anchors to take users to specific parts of a long page. But I want to add some processing and do some things with my nav bar when users go to certain sections delineated by named...
3
by: gary | last post by:
Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is located in a "/include" folder If you have a...
6
by: Nalaka | last post by:
Hi, Is there a gui control in VS2005 to set a "named anchor"? For an example now I go to the html and write the following code <a name="jumpToThisLocation"/>
12
by: deko | last post by:
I have a long page with several sections and want to link to these sections from another page like this: <a href='http://www.mysite.com/content.html#section12'>Section 12</a> Here's what the...
1
by: Alec MacLean | last post by:
Hi. I'm using VS2005 Pro to work on a website project for my company. The site has several navigation elements, all based on the standard VS2005 navigation components. I have high-level...
3
by: Joseph Gruber | last post by:
Hi all -- I have two questions. First, I'm adding a control to my form at runtime and the control/form seems to ignore the anchor property of the runtime control. Any idea how I can get a...
8
by: azjudd | last post by:
Thank you in advance for your help on this one. I'm using named anchor tags on a FAQ page with questions listed at the top and answers below; a standard jump-to feature. However, anytime an anchor...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.