如何根据条件设置链接按钮的状态?

时间:2015-03-02 14:45:39

标签: c# css asp.net twitter-bootstrap

我有2个链接按钮,它们链接到多视图,具体取决于我推送哪个会更改活动视图。我希望它的各个视图的链接按钮显示为活动状态。



<asp:Panel runat="server" >
        <div>
            <asp:LinkButton ID="linkDeviceList"  CommandName="SwitchViewByID" CommandArgument="viewDeviceList" runat="server" OnClick="linkDeviceList_Click" CssClass="button-link">Device List</asp:LinkButton>
            <asp:LinkButton ID="linkFTPFolders"  CommandName="SwitchViewByID" CommandArgument="viewFTPFolders" runat="server" OnClick="linkFTPFolders_Click" CssClass="button-link">FTP Folders</asp:LinkButton>           
        </div>
    </asp:Panel>
&#13;
&#13;
&#13;

事件处理程序。我假设我在&#39;中更改了按钮的状态。但无法弄清楚如何应用风格变化。

&#13;
&#13;
protected void linkFTPFolders_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(viewFTPFolders);

        while (MultiView1.GetActiveView() == viewFTPFolders)
        {
            
        }
    }

    protected void linkDeviceList_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(viewDeviceList);
        while (MultiView1.GetActiveView() == viewDeviceList)
        {
            
        }
    }
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我有类似的控制权。这就是我所做的。

  1. 我在点击的按钮上删除/添加了“活动”类。
  2. 我禁用了点击的按钮,因此无法点击该按钮 试。

        protected void lbListView_Click(object sender, EventArgs e)
        {
            lbGridView.CssClass = "btn btn-default btn-sm pull-right dt-margin-left-5";
            lbGridView.Enabled = true;
    
            lbListView.CssClass = "btn btn-default btn-sm pull-right dt-margin-left-5 active";
            lbListView.Enabled = false;
    
            repGridResults.Visible = false;
            repListResults.Visible = true;
        }
    
        protected void lbGridView_Click(object sender, EventArgs e)
        {
            lbListView.CssClass = "btn btn-default btn-sm pull-right dt-margin-left-5";
            lbListView.Enabled = true;
    
            lbGridView.CssClass = "btn btn-default btn-sm pull-right dt-margin-left-5 active";
            lbGridView.Enabled = false;
    
            repListResults.Visible = false;
            repGridResults.Visible = true;
        }