Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的页面中,我有一个用于搜索和过滤的 ajax 调用,以及我在 URL 中作为#参数附加的所有过滤器选择(以查询字符串的形式附加它将刷新页面)。
#
我的问题是我无法#在后面的代码中访问这个(值)(使用c#)。
我试图将#值存储在javascript函数的隐藏字段window.load中,但我不会在asp.net的页面加载方法中获取此值。
window.load
有人可以建议如何在页面加载时访问此值吗?
好吧,#不会发送到服务器(它不在请求中),您可以通过 javascript 访问它,例如:
var hash = window.location.hash; if (hash !== "") { hash = hash.substring(1); alert(hash); }
如果您必须在服务器上访问它,我担心您必须放置一个查询字符串:
http://yoururl/?test=123
然后你访问:Request.QueryString["test"]- 会给你123。
Request.QueryString["test"]