后回传C#仍引导标签 [英] Remain bootstrap tab after postback c#
问题描述
目前我有我的文件上传回发后保留引导标签的问题。
在code是如下
I am currently having problem retaining the bootstrap tab after my fileupload postback. The code is as follow
<script type="text/javascript">
$('#myTab a[href="#image"]').click(function (e) {
e.preventDefault();
$("#myTab").removeClass("active");
$(this).addClass('active');
$(this).tab('show');
})
$('#myTab a[href="#information"]').click(function (e) {
e.preventDefault();
$("#myTab").removeClass("active");
$(this).addClass('active');
$(this).tab('show');
})
$('#myTab a[href="#password"]').click(function (e) {
e.preventDefault();
$("#myTab").removeClass("active");
$(this).addClass('active');
$(this).tab('show');
})
$('#myTab a[href="#account"]').click(function (e) {
e.preventDefault();
$("#myTab").removeClass("active");
$(this).addClass('active');
$(this).tab('show');
})
</script>
任何人都可以启发我如何回传后保留此引导?
Can anyone enlighten me on how to retain this bootstrap after postback?
推荐答案
好了,我已经有这个问题,我解决了它这种方式:
Well, I had this issue already and I solved it this way:
-
包含一个新的
HiddenField
您的网页,并将其值设置为第一设置页
那需要显示:
Include a new
HiddenField
on your page and set its value to the firsttab
that need to be shown:
<asp:HiddenField ID="hidTAB" runat="server" Value="image" />
在每个点击
您定义交替的标签功能
,将 HiddenField
值实际设置页
点击
On every click
function you defined to alternate the tabs
, set the HiddenField
value to the actual tab
clicked.
document.getElementById('<%=hidTAB.ClientID %>').value = "image";
在你的的jQuery
的document.ready
功能,使用 HiddenField
值交替前打开的最后一个选项卡中的回发
。
On your jQuery
document.ready
function, use the HiddenField
value to alternate to the last tab opened before the Postback
.
$(document).ready( function(){
var tab = document.getElementById('<%= hidTAB.ClientID%>').value;
$( '#myTab a[href="' + tab + '"]' ).tab( 'show' );
});
这篇关于后回传C#仍引导标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!