asp.net自举回来后事件后,保持当前激活的选项卡 [英] asp.net bootstrap Keep current active tab after post-back event
问题描述
我有以下asp.net ASPX code
I have the following asp.net aspx code
<asp:LinkButton CssClass="form-search" ID="LinkButtonSearch" runat="server">Search</asp:LinkButton>
<br />
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#home">Home</a></li>
<li><a href="#profile">Profile</a></li>
<li><a href="#messages">Messages</a></li>
<li><a href="#settings">Settings</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="home">home</div>
<div class="tab-pane" id="profile">profile</div>
<div class="tab-pane" id="messages">messages</div>
<div class="tab-pane" id="settings">settings</div>
</div>
本脚本code不断回后事件后的活动选项卡时,我对LinkButton的
This script code keeps the active tab after post-back event when i click on the LinkButton
<script>
$(document).ready( function(){
$('#myTab a').click(function (e) {
e.preventDefault()
$(this).tab('show')
});
// store the currently selected tab in the hash value
$("ul.nav-tabs > li > a").on("shown.bs.tab", function (e) {
var id = $(e.target).attr("href").substr(1);
window.location.hash = id;
});
// on load of the page: switch to the currently selected tab
var hash = window.location.hash;
$('#myTab a[href="' + hash + '"]').tab('show');
});
</script>
注:此code正常工作,只有当我重新加载当前页。它使当前选项卡的焦点。但是当u点击链接按钮,它把我带回到默认的选项卡。
NB: This code works fine only when i reload the current page. It keeps the current tab focus. but when u click on the Link Button, it takes me back to the default tab.
如何才能让这个code也对任何控件的回发事件的工作。
How can make this code also work on the post back event of any controls.
请注意:我把从叠后这个例子:<一href=\"http://stackoverflow.com/questions/10523433/how-do-i-keep-the-current-tab-active-with-twitter-bootstrap-after-a-page-reload?rq=1\">How做我保持当前标签主动与Twitter的引导页面重新加载后?。该解决方案已张贴:@koppor
Note: i took this example from the stack post : How do I keep the current tab active with twitter bootstrap after a page reload? . This solution has been posted by: @koppor.
任何帮助
推荐答案
我想你的脚本,它解决了我的问题之一,我添加了这个$ C $ C到我的提交按钮
I tried your script and it solved one of my problems, i added this code to my submit button
的Response.Redirect(Settings.aspx#步骤2);
Response.Redirect("Settings.aspx#step2");
希望工程为您的
这篇关于asp.net自举回来后事件后,保持当前激活的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!