多个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;
}
posted @ 2015-01-07 09:10  峰之巅的云  阅读(213)  评论(0编辑  收藏  举报