gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 08:19:52 25 4
gpt4 key购买 nike

我有 2 个链接按钮,它们链接到一个多 View ,并且根据我按下的按钮将更改事件 View 。我希望它各自 View 的链接按钮显示为事件状态。

<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>

事件处理程序。我假设我会在“一段时间”内更改按钮的状态,但不知道如何应用样式更改。

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)
{

}
}

最佳答案

我有一个类似的控件。这就是我所做的。

  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;
    }

关于c# - 如何根据条件设置链接按钮的状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28812550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com