首页 > 代码库 > 多个LinkButton导航

多个LinkButton导航

界面:
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton_Click">导航1</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton_Click">导航2</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton_Click">导航3</asp:LinkButton>
<asp:LinkButton ID="LinkButton4" runat="server" OnClick="LinkButton_Click">导航4</asp:LinkButton>
<asp:LinkButton ID="LinkButton5" runat="server" OnClick="LinkButton_Click">导航5</asp:LinkButton>

</asp:PlaceHolder>
<br />
<asp:LinkButton ID="LinkButton6" runat="server">其他LinkButton</asp:LinkButton>

CS文件加一个事件:
protected void LinkButton_Click(object sender, EventArgs e)
{
foreach (Control c in PlaceHolder1.Controls)
{
if (c is LinkButton)
{
(c as LinkButton).Enabled = true;
}
}
(sender as LinkButton).Enabled = false;
}

多个LinkButton导航