后回传C#仍引导标签 [英] Remain bootstrap tab after postback c#

查看:295
本文介绍了后回传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:


  1. 包含一个新的 HiddenField 您的网页,并将其值设置为第一设置页那需要显示:

  1. Include a new HiddenField on your page and set its value to the first tab 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' );
    });
    


  • 这里的引导标签文档和的这里的jQuery的准备文档

    这篇关于后回传C#仍引导标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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