Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在c#.net母版页中设置活动类_C#_Jquery_Asp.net_Twitter Bootstrap_Master Pages - Fatal编程技术网

在c#.net母版页中设置活动类

在c#.net母版页中设置活动类,c#,jquery,asp.net,twitter-bootstrap,master-pages,C#,Jquery,Asp.net,Twitter Bootstrap,Master Pages,我想根据访问的链接在li标签中设置活动类,我尝试了Stackoverflow的几个答案,但在我看来没有一个有效 仅供参考,我正在使用Bootstrap、C#和Visual Studio进行开发。您的元素应该如下所示(在master.page中): 您可以使用Jquery实现它 首先在you li标记中的所有锚定标记上设置单个类,即: this.Master.linkDefault = "active"; 希望它能起作用。我把你的jQuery放在母版的首页(甚至试着放在正文上),但还是跟着你的帖

我想根据访问的链接在li标签中设置活动类,我尝试了Stackoverflow的几个答案,但在我看来没有一个有效


仅供参考,我正在使用Bootstrap、C#和Visual Studio进行开发。

您的元素应该如下所示(在master.page中):


您可以使用Jquery实现它

首先在you li标记中的所有锚定标记上设置单个类,即:

this.Master.linkDefault = "active";

希望它能起作用。

我把你的jQuery放在母版的首页(甚至试着放在正文上),但还是跟着你的帖子走了。但是还没有运气!
<li role="presentation" id="liDefault" runat="server"><a href="Default.aspx">Home</a></li>

public String linkDefault
{
    get 
    {
        return "not_active";
    }
    set
    {
        liDefault.Attributes.Add("class", "" + value + "");
    }
}
<%@ MasterType VirtualPath="~/MasterPage.master" %>
this.Master.linkDefault = "active";
<div id="navigation"> 
   <ul class="nav nav-pills">
      <li role="presentation"><a href="Default.aspx" class="link">Home</a></li>
      <li role="presentation"><a href="open-account.aspx" class="link">Open Account</a></li>
      <li role="presentation"><a href="atm_authenticate.aspx" class="link">ATM</a></li>
      <li role="presentation"><a href="#" class="link">Branch Locator</a></li>
      <li role="presentation"><a href="#" class="link">Contact US</a></li>
   </ul>
</div>
$(".link").click(function(){
   $(this).parent().addClass("active");
})