Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Get the named anchor from the URL?

Reply
Thread Tools

Get the named anchor from the URL?

 
 
Greg Collins [Microsoft MVP]
Guest
Posts: n/a
 
      10-11-2006
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 )


 
Reply With Quote
 
 
 
 
bruce barker \(sqlwork.com\)
Guest
Posts: n/a
 
      10-11-2006
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_com> wrote in message
news:...
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 )



 
Reply With Quote
 
 
 
 
apathetic
Guest
Posts: n/a
 
      10-11-2006
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

 
Reply With Quote
 
apathetic
Guest
Posts: n/a
 
      10-11-2006
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

 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      10-11-2006
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)" <> wrote in message
news:...
> 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_com> wrote in message
> news:...
> 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]



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      10-11-2006
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" <> wrote in message
news: 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
>



 
Reply With Quote
 
Greg Collins [Microsoft MVP]
Guest
Posts: n/a
 
      10-12-2006
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 )


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to - named anchor on another page? help please netrate@yahoo.com HTML 1 03-30-2006 10:46 PM
named anchor Nalaka ASP .Net 6 12-29-2005 01:17 AM
Named anchor question Mark Parnell HTML 3 06-28-2005 08:17 PM
Help understanding HTML "Named Anchor" Jeff Wisnia Computer Support 3 04-06-2005 04:48 AM
Jump to named anchor after form processing Robert Mark Bram ASP General 3 10-20-2004 11:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57