使用 ASP.NET Webforms 在另一个页面上打开特定选项卡

Open specific tab on another page with ASP.NET Webforms

我有一个网络表单网站,我正在使用 Bootstrap。我的页脚中有几个 link,它们会 link 到不同页面上的各个选项卡。我的问题是,无论我指定 link 打开哪个选项卡,它们都只加载带有默认选项卡的页面。

我在静态网站上做过几次,但从未在 ASP.NET 上做过。我认为问题出在 ASP.NET 将 .aspx 添加到每个页面的末尾。

这是我尝试过的:

<a href="/Personal-Banking.aspx#checking">Checking Accounts</a>

因此,我link要访问的页面是个人-Banking.aspx,我要打开的选项卡的 ID 是#checking。现在所做的只是打开个人银行页面并打开默认选项卡,这与#checking 选项卡不同。

我已经尝试删除 .aspx,但它仍然无法正确打开并且图像全部损坏。

感谢您的帮助。

检查您 link 访问的网页,当您访问该网页时,请在浏览器上查看该网页的来源。该选项卡的 ID 真的是 "checking",还是像 "MainContent_TabbedPanel_checking"?

不要看你的代码,看你的浏览器得到了什么。

这是用于获取选项卡链接以在 asp.net 网络表单中工作的代码:

<!--Update this to reflect tabs on this page-->
    <script type="text/javascript">
        $(function () {
            var loc = window.location.href; // returns the full URL
            if (/pipe/.test(loc)) {
                $('.pipe').addClass('active');
                $('#pipe').addClass('active');
            }
            else if (/manholes/.test(loc)) {
                $('.manholes').addClass('active');
                $('#manholes').addClass('active');
            }
            else if (/fittings/.test(loc)) {
                $('.fittings').addClass('active');
                $('#fittings').addClass('active');
            }
            else if (/tanks/.test(loc)) {
                $('.tanks').addClass('active');
                $('#tanks').addClass('active');
            }
            else {
                $('.pipe').addClass('active');
                $('#pipe').addClass('active');
            }
        });
    </script>