[英]Retain anchor after postback in asp.net
I'm using a coda slider like consctuct on one of my pages. 我在其中一页上使用像consctuct这样的尾迹滑块 。 Naturally, the anchor ("#currentTab") information is lost after a postback.
自然,回发后锚(“ #currentTab”)信息会丢失。 This is annoying because when you press a button on a certain tab, you always end up on the first tab after the postback.
这很烦人,因为当您按下某个选项卡上的按钮时,您总会在回发之后最终出现在第一个选项卡上。
What is the best way of letting this information survive a postback? 让这些信息保留回发的最佳方法是什么?
尝试这是您的page_load
事件
Me.Form.Attributes("onsubmit") = "this.action+=top.location.hash;"
I'm not doing in ASP, but as a general solution attempt this might work for you too: 我不在ASP中进行操作,但是作为一种一般的解决方案尝试,这也可能对您有用:
Either execute your postback as an AJAX request, or add some javascript to the form that will send the anchor value to the server 作为AJAX请求执行回发,或将一些javascript添加到将锚定值发送到服务器的表单中
Rough example 粗略的例子
<form onsubmit="this.anchor.value=top.location.hash">
<input name="anchor" type="hidden" value="">
<!-- rest of form -->
</form>
Then you'll need a convention to return it to the client and perform the appropriate action. 然后,您将需要一个约定以将其返回给客户端并执行适当的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.