[英]Open specific tab on another page with ASP.NET Webforms
我有一个webforms网站,我正在使用Bootstrap。 我的页脚中有一些链接会链接到不同页面上的各个标签。 我的问题是,无论在哪个选项卡中指定要打开的链接,它们只会使用默认选项卡加载页面。
我已经使用静态站点多次完成此操作,但从未使用ASP.NET。 我相信问题在于ASP.NET将.aspx添加到每个页面的末尾。
这是我尝试过的:
<a href="/Personal-Banking.aspx#checking">Checking Accounts</a>
所以,我链接到的页面是Personal-Banking.aspx,而我想要打开的标签的ID是#checking。 现在所做的就是打开个人银行页面并打开默认选项卡,该选项卡与#checking选项卡不同。
我已经尝试删除.aspx但它仍然无法正确打开并且图像都被破坏了。
谢谢您的帮助。
检查您链接到的页面,查看浏览器上的网页来源。 该选项卡的ID
是否真的"checking"
,还是像"MainContent_TabbedPanel_checking"
?
不要查看您的代码,看看您的浏览器获得了什么。
以下是用于链接到标签以在asp.net webforms中工作的代码:
<!--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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.