问题描述
我在单个页面中使用了4个ModalPopupExtender.当我运行该特定页面时,甚至在Button_Click操作之前,我在ModalPopupExtender下使用的所有面板都会弹出.每当页面加载时,我都无法找到隐藏它们的方法,而仅在按下相应按钮时才弹出它们.到现在为止,我一直尝试为面板设置visible ="false",但这也完全解决了我的问题.谢谢你.
I am using 4 ModalPopupExtender in a single page. When I run that specific page all the panels which I have used under ModalPopupExtender gets popped up even before the Button_Click action. I am not able to find a way to hide them whenever a page loads and only pop up them when respective button is pressed. Till now I tried to set visible = "false" for panels, but that dint solved my problem completely either. Thank you.
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type = "text/css">
.panel
{
background : gray;
padding : 10px;
}
div ul ul
{
display: none;
}
div ul li:hover > ul
{
display: block;
}
div ul li ul:hover > ul
{
display: block;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 548px; width: 1337px; ">
<br /><br />
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="XX-Large" Text="Automated Examination System"></asp:Label><br /> <br /><br />
<asp:Panel ID = "Panel1" runat = "server" Height="181px" Width="275px">
<ul>
<li style="margin-removed 33px; width: 169px;"> <asp:LinkButton ID = "LinkAdmin" runat = "server" onclick="LinkAdmin_Click">Coordinator</asp:LinkButton></li>
<li style="width: 172px; margin-removed 33px"> <asp:LinkButton ID="LinkStaff" runat="server" onclick="LinkStaff_Click">Staff</asp:LinkButton></li>
<li style="margin-removed 33px"> <asp:LinkButton ID = "LinkStudent" runat = "server">Student</asp:LinkButton>
<ul>
<li><asp:LinkButton ID = "LinkButton1" runat = "server" onclick="FreshRegistration_Click">Fresh Registration</asp:LinkButton></li>
<li><asp:LinkButton ID = "LinkButton2" runat = "server" onclick="ReRegistration_Click">Re Registration</asp:LinkButton></li>
</ul>
</li>
</ul>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" style="left: 290px; top: 104px; position: absolute; height: 354px; width: 611px"><br /><br /><br />
<asp:Label ID="Label2" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="The Automated Examination system will allow post graduation student and under graduation students to register their respective courses for their respective semester. "></asp:Label>
<asp:Label ID="Label3" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="Once the registration process is completed for a student the system sends information to the controller of examination."></asp:Label><br />
<asp:Label ID="Label4" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="Each staff will be able to enter the CIE1 and CIE2 marks based on the privileges provided by coordinator of that respective department. "></asp:Label><br />
<asp:Label ID="Label5" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="Once the staff enters marks for CIE1/CIE2, they won’t be allowed to make changes later on. "></asp:Label><br />
<asp:Label ID="Label6" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="After submitting the marks, the staff will be given with print out of the entered marks for further reference. "></asp:Label><br />
<asp:Label ID="Label7" runat="server" Font-Bold="False" Font-Italic="False" Font-Names="Arial" Font-Size="Medium" Text="At the end of a semester each student SGPA is calculated and the controller take a back up copy of grade cards and result sheet of all the students. "></asp:Label><br />
<asp:Label ID="Label9" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="Since student grades are sensitive information certain measures are taken to prevent unauthorized access. "></asp:Label><br />
<asp:Label ID="Label8" runat="server" Font-Bold="False" Font-Names="Arial" Font-Size="Medium" Text="The system also generate the transcript of student which contains all semester marks, Course Title in that particular semester, SGPA of each semester and overall CGPA of that student. "></asp:Label>
</asp:Panel>
<asp:Panel ID="Panel5" runat="server" style= "left: 906px; top: 105px; position: absolute; " Visible="False" Width="430px"><br/>
<asp:Label ID="Label10" runat="server" Text="Coordinator Login"></asp:Label><br /><br />
<asp:Label ID="Label16" runat="server" Text="Select Department : "></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" ValidationGroup="AdminLogin"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="DropDownList1" ErrorMessage="Department is blank" ForeColor="Red" ValidationGroup="AdminLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label17" runat="server" Text="Select Branch : "></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" ValidationGroup="AdminLogin"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="DropDownList2" ErrorMessage="Branch is blank" ForeColor="Red" ValidationGroup="AdminLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label11" runat="server" Text="Username : "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" ValidationGroup="AdminLogin" style="height: 22px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="TextBox1" ErrorMessage="Username is blank" ForeColor="Red" ValidationGroup="AdminLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label12" runat="server" Text="Password : "></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password" ValidationGroup="AdminLogin"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="TextBox2" ErrorMessage="Password is blank" ForeColor="Red" ValidationGroup="AdminLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Login" Width="80px" ValidationGroup="AdminLogin" />
<asp:Button ID="NewAdminSignUp" runat="server" Text="New Coordinator" Width="110px" />
<asp:Button ID="Button5" runat="server" Text="Forgot Password"/>
</asp:Panel>
<asp:Panel ID="Panel4" runat="server" style="left: 906px; top: 105px; position: absolute;" Visible="False" Width="430px"><br />
<asp:Label ID="Label13" runat="server" Text="Staff Login"></asp:Label><br /><br />
<asp:Label ID="Label14" runat="server" Text="Username : "></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" Width="127px" ValidationGroup="StaffLogin"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ControlToValidate="TextBox3" ErrorMessage="Username is blank" ForeColor="Red" ValidationGroup="StaffLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label15" runat="server" Text="Password : "></asp:Label>
<asp:TextBox ID="TextBox4" runat="server" TextMode="Password" ValidationGroup="StaffLogin"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server" ControlToValidate="TextBox4" ErrorMessage="Password is blank" ForeColor="Red" ValidationGroup="StaffLogin"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="Button2" runat="server" Text="Login" Width="80px" onclick="Button2_Click" ValidationGroup="StaffLogin" />
<asp:Button ID="NewStaffSignUp" runat="server" Text="New Staff" Width="82px" />
<asp:Button ID="StaffFP" runat="server" Text="Forgot Password" Width="110px" />
</asp:Panel>
<asp:Panel ID="StaffPanl3" CssClass = "panel" runat="server" Height="282px" Width="515px">
<asp:Label ID="Label24" runat="server" Font-Size="XX-Large" ForeColor="#99FFCC" Text="New Staff Sign Up"></asp:Label><br /><br />
<asp:Label ID="Label20" runat="server" Text="Enter Course Code : " ForeColor="White"></asp:Label>
<asp:TextBox ID="TextBox9" runat="server" ValidationGroup="grp1"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox9" ErrorMessage="Course Code is left blank" ForeColor="#FF3300" ValidationGroup="grp1"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label21" runat="server" ForeColor="White" Text="Enter Password : "></asp:Label>
<asp:TextBox ID="TextBox10" runat="server" TextMode="Password" ValidationGroup="grp1"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox10" ErrorMessage="Password is left blank" ForeColor="#FF3300" ValidationGroup="grp1"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label22" runat="server" ForeColor="White" Text="Retype Password : "></asp:Label>
<asp:TextBox ID="TextBox11" runat="server" TextMode="Password" ValidationGroup="grp1"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox10" ControlToValidate="TextBox11" ErrorMessage="Password Missmatch" ForeColor="#FF3300" ValidationGroup="grp1"></asp:CompareValidator><br /><br />
<asp:Label ID="Label23" runat="server" ForeColor="White" Text="Password Hint : "></asp:Label>
<asp:TextBox ID="TextBox12" runat="server" TextMode="Password" ValidationGroup="grp1"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox12" ErrorMessage="Hint is left blank" ForeColor="#FF3300" ValidationGroup="grp1"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="StaffSignUp" runat="server" Text="Sign Up" ValidationGroup="grp1" />
<asp:Button ID="StaffCancel" runat="server" Text="Cancel" /><br /> <br /><br />
</asp:Panel>
<asp:Panel ID="AdminPanl3" CssClass = "panel" runat="server" Height="355px" Width="515px">
<asp:Label ID="Label25" runat="server" Font-Size="XX-Large" ForeColor="#99FFCC" Text="New Coordinator Sign Up"></asp:Label><br /><br />
<asp:Label ID="Label18" runat="server" Text="Select Department : " ForeColor="White"></asp:Label>
<asp:DropDownList ID="DropDownList3" runat="server"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="DropDownList3" ErrorMessage="Select Department" ForeColor="#FF3300" ValidationGroup="grp2"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label19" runat="server" Text="Select Branch : " ForeColor="White"></asp:Label>
<asp:DropDownList ID="DropDownList4" runat="server"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="DropDownList4" ErrorMessage="Select Branch" ForeColor="#FF3300" ValidationGroup="grp2"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label26" runat="server" Text="Enter Username : " ForeColor="White"></asp:Label>
<asp:TextBox ID="TextBox13" runat="server" ValidationGroup="grp2"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBox13" ErrorMessage="Username is left blank" ForeColor="#FF3300" ValidationGroup="grp2"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label27" runat="server" ForeColor="White" Text="Enter Password : "></asp:Label>
<asp:TextBox ID="TextBox14" runat="server" TextMode="Password" ValidationGroup="grp2"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="TextBox14" ErrorMessage="Password is left blank" ForeColor="#FF3300" ValidationGroup="grp2"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label28" runat="server" ForeColor="White" Text="Retype Password : "></asp:Label>
<asp:TextBox ID="TextBox15" runat="server" TextMode="Password" ValidationGroup="grp2"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="TextBox14" ControlToValidate="TextBox15" ErrorMessage="Password Missmatch" ForeColor="#FF3300" ValidationGroup="grp2"></asp:CompareValidator><br /><br />
<asp:Label ID="Label29" runat="server" ForeColor="White" Text="Password Hint : "></asp:Label>
<asp:TextBox ID="TextBox16" runat="server" TextMode="Password" ValidationGroup="grp2"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="TextBox16" ErrorMessage="Hint is left blank" ForeColor="#FF3300" ValidationGroup="grp2"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="AdminSignUp" runat="server" Text="Sign Up" ValidationGroup="grp2" />
<asp:Button ID="AdminCancel" runat="server" Text="Cancel" /><br />
</asp:Panel>
<asp:Panel ID="Panel3" CssClass = "panel" runat="server" Width="514px">
<asp:Label ID="Label36" runat="server" Font-Size="XX-Large" ForeColor="#99FFCC" Text="Staff Forgot Password"></asp:Label><br /><br />
<asp:Label ID="Label38" runat="server" ForeColor="White" Text="Enter Username : "></asp:Label>
<asp:TextBox ID="FrogtPasswordStaffTXT" runat="server" ValidationGroup="FrgotPasswordStaff"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator21" runat="server" ControlToValidate="FrogtPasswordStaffTXT" ErrorMessage="Username is left blank" ForeColor="#FF3300" ValidationGroup="FrgotPasswordStaff"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label35" runat="server" ForeColor="White" Text="Enter Password Hint : "></asp:Label>
<asp:TextBox ID="FrogtPasswordStaffTXTHINT" runat="server" TextMode="Password" ValidationGroup="FrgotPasswordStaff"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator19" runat="server" ControlToValidate="FrogtPasswordStaffTXTHINT" ErrorMessage="Hint is left blank" ForeColor="#FF3300" ValidationGroup="FrgotPasswordStaff"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="Staffgtpass" runat="server" Text="Get Password" ValidationGroup="FrgotPasswordStaff" />
<asp:Button ID="StaffCancelBtn" runat="server" Text="Cancel" /><br />
</asp:Panel>
<asp:Panel ID="Panel6" CssClass = "panel" runat="server" Height="272px" Width="515px">
<asp:Label ID="Label39" runat="server" ForeColor="#99FFCC" Text="Admin Forgot Password" Font-Size="XX-Large"></asp:Label><br /><br />
<asp:Label ID="Label43" runat="server" Text="Select Department : " ForeColor="White"></asp:Label>
<asp:DropDownList ID="DropDownList5" runat="server" ValidationGroup="AdminForgot"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator22" runat="server" ControlToValidate="DropDownList5" ErrorMessage="RequiredFieldValidator" ForeColor="Red" ValidationGroup="AdminForgot"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label40" runat="server" ForeColor="White" Text="Select Branch : "></asp:Label>
<asp:DropDownList ID="DropDownList6" runat="server" ValidationGroup="AdminForgot"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator23" runat="server" ControlToValidate="DropDownList6" ErrorMessage="RequiredFieldValidator" ForeColor="Red" ValidationGroup="AdminForgot"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label41" runat="server" ForeColor="White" Text="Enter Username : "></asp:Label>
<asp:TextBox ID="TextBox17" runat="server" ValidationGroup="AdminForgot"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator24" runat="server" ControlToValidate="TextBox17" ErrorMessage="RequiredFieldValidator" ForeColor="Red" ValidationGroup="AdminForgot"></asp:RequiredFieldValidator><br /><br />
<asp:Label ID="Label42" runat="server" ForeColor="White" Text="Enter Password Hint : "></asp:Label>
<asp:TextBox ID="TextBox18" runat="server" TextMode="Password" ValidationGroup="AdminForgot"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator25" runat="server" ControlToValidate="TextBox18" ErrorMessage="RequiredFieldValidator" ForeColor="Red" ValidationGroup="AdminForgot"></asp:RequiredFieldValidator><br /><br />
<asp:Button ID="Button3" runat="server" Text="Get Password" ValidationGroup="AdminForgot" />
<asp:Button ID="Button4" runat="server" Text="Cancel" />
</asp:Panel>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" DropShadow = "true" CancelControlID = "AdminCancel" PopupControlID="AdminPanl3" TargetControlID="NewAdminSignUp"></cc1:ModalPopupExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" DropShadow = "true" CancelControlID = "StaffCancel" PopupControlID="StaffPanl3" TargetControlID="NewStaffSignUp"> </cc1:ModalPopupExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtender3" runat="server" DropShadow = "true" CancelControlID = "Button4" PopupControlID = "Panel6" TargetControlID = "Button5"></cc1:ModalPopupExtender>
<cc1:ModalPopupExtender ID="ModalPopupExtender4" runat="server" DropShadow = "true" CancelControlID = "StaffCancelBtn" PopupControlID = "Panel3" TargetControlID = "StaffFP"></cc1:ModalPopupExtender>
</div>
</form>
</body>
</html>
LinkStaff and LinkAdmin are two link buttons which I am using to popup the login for both using below code.
LinkStaff and LinkAdmin are two link buttons which I am using to popup the login for both using below code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkAdmin_Click(object sender, EventArgs e)
{
Panel4.Visible = false;
Panel5.Visible = true;
}
protected void LinkStaff_Click(object sender, EventArgs e)
{
Panel5.Visible = false;
Panel4.Visible = true;
}
}
推荐答案
.hidePanel {display:none;}
Assign css class to panels
Assign css class to panels
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
AdminPanl3.CssClass = "hidePanel";
StaffPanl3.CssClass = "hidePanel";
Panel6.CssClass = "hidePanel";
Panel3.CssClass = "hidePanel";
}
}
...希望能帮上忙.
... hope it helps.
这篇关于如何在单个asp.net中使用多模ModalPopupExtender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!