检索锚链接URL中的ASP.Net [英] Retrieving Anchor Link In URL for ASP.Net

查看:117
本文介绍了检索锚链接URL中的ASP.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址,像这样:

I have an url like so:

<一个href=\"http://localhost/place/663828/bangkok-paradise-restaurant-toronto#r306040\">http://localhost/place/663828/bangkok-paradise-restaurant-toronto#r306040

我想看看是否有得到它的价值做一些code逻辑在code后面那里有锚标记的存在一起。

I am trying to see if theres the existence of the anchor tag along with getting it's value to do some code logic in the code behind.

我一直在尝试使用Page.Request,但没有属性显示的URL的锚链接部分。

I have been trying to use the Page.Request, but none of the properties show the anchor link portion of the url.

例如:

的Response.Write(this.Page.Request.RawUrl.ToString());

Response.Write(this.Page.Request.RawUrl.ToString());

pretty多尝试这个页面上的组合/属性:<一个href=\"http://www.west-wind.com/weblog/posts/269.aspx\">http://www.west-wind.com/weblog/posts/269.aspx

Pretty much tried the combinations/properties on this page: http://www.west-wind.com/weblog/posts/269.aspx

只是为了完成这个主题:

Just to finalize this topic:

我复制#1的方式与固定链接...:D

I copied Stackoverflow's approach with permalink... :D

推荐答案

这是不可能检索ASP.NET中的服务器端#anchor

It's not possible to retrieve the #anchor from the server side in ASP.NET

这是一个客户端标志告诉浏览器移动到页面中的特定位置。

This is a client-side flag to tell the browser to move to a specific place within the page.

您可以使用一些JavaScript在体内onLoad事件来检查锚和使用AJAX发送回服务器。

You can use some Javascript in the body onLoad event to check for an anchor and send it back to the server using ajax.

var anchorValue;
var url = document.location;
var strippedUrl = url.toString().split("#");
if(strippedUrl.Length > 1)
anchorvalue = strippedUrl[1];

REF:<一href=\"http://www.wacdesigns.com/2008/01/16/retrieving-anchor-value-from-url/\">http://www.wacdesigns.com/2008/01/16/retrieving-anchor-value-from-url/

这篇关于检索锚链接URL中的ASP.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆