页面锁定
功能描述:点击页面中“button”按钮后将 原先不显示的“Panel”显示出,并且在这时将页面其他按钮设置成不可用状态,只能操作 "Panel "容器中的控件。
------解决方案--------------------protected void Button1_Click(object sender, EventArgs e)
{
foreach (Control ctrl in Page.Form.Controls) {
if (ctrl is Button && !ctrl.Equals(sender)) {
((Button)ctrl).Enabled = false;
}
}
Panel1.Visible = true;
}
------解决方案--------------------完整代码:
<%@ Page Language= "C# " %>
<%--http://community.csdn.net/Expert/TopicView3.asp?id=5619726--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "server ">
protected void Button1_Click(object sender, EventArgs e)
{
foreach (Control ctrl in Page.Form.Controls) {
// 如果同时需要灰化切换事件按钮请去掉 && !ctrl.Equals(sender)
if (ctrl is Button && !ctrl.Equals(sender)) {
((Button)ctrl).Enabled = false;
}
}
Panel1.Visible = true;
}
</script>
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Untitled Page </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "Button " />
<asp:Panel ID= "Panel1 " runat= "server " Height= "50px " Width= "125px " BorderWidth= "1 " Visible= "false ">
<asp:Button ID= "Button3 " runat= "server " Text= "Button " />
<asp:Button ID= "Button2 " runat= "server " Text= "Button " /> </asp:Panel>
<asp:Button ID= "Button4 " runat= "server " Text= "Button " />
<asp:Button ID= "Button5 " runat= "server " Text= "Button " /> </div>
</form>
</body>
</html>
------解决方案--------------------你做那么多,还不如直接添加一个层z-index设置大点,覆盖那些控件,然后你的panel的z-index的值再比层的z-index值大点。
就完了嘛,何必那么复杂?