就是一个用户登录的div窗体,当没有输入账号和密码。在点击登录按钮时弹出的Div窗体不关闭。
下面是我的从code:
<div id="loginBox">
<table>
<tr>
<td rowspan="4" width="20px"> </td>
<td align="right" width="50px">
<asp:Label ID="lblID" runat="server" Text="帐号:"></asp:Label>
</td>
<td colspan="2">
<input id="txtAccount" type="text" runat="server" maxlength="50" />
</td>
<td rowspan="5">
<asp:ImageButton ID="imgBtnLoginLarge" runat="server" ImageUrl="images/login/login_button_login.png" BorderWidth="0px"
ImageAlign="Middle" Width="96px" Height="96px" OnClick="imgbtnLogin_Click" OnClientClick="LockPage();" />
</td>
</tr>
<tr>
<td align="right" width="50px">
<asp:Label ID="lblPassword" runat="server" Text="密码:"></asp:Label>
</td>
<td colspan="2">
<input id="txtPassword" runat="server" type="password" maxlength="19" />
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><a href="WebPage/Account/AccountRegistrationForEyeII.aspx?type=1" onclick="LockPage();">
<%= GetString("DEFAULT_REGISTER_EYEII")%></a> <a href="WebPage/Account/ForgetID.aspx?type=1" onclick="LockPage();">
<%= GetString("DEFAULT_FORGET_ID")%></a></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><a href="WebPage/Account/ForgetPassword.aspx?type=1" onclick="LockPage();">
<%= GetString("DEFAULT_FORGET_PASSWORD")%></a> <a href="WebPage/Account/ResendActivationEmailOrSMS.aspx?type=1" onclick="LockPage();">
<%= GetString("DEFAULT_RESEND_ACTIVATION_EMAIL")%></a></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"><asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label></td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td colspan="4"><img src="images/login/login_desc.png"></td>
<td><a href="WebPage/Account/AccountRegister.aspx?type=1" onclick="LockPage();"><img src="images/login/login_button_register.png"></a></td>
</tr>
</table>
</div>
<div id="loginBoxClose">
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"><img src="images/login/login_button_close.png"></a>
</div>
下面是我的从code:
<div id="loginBox">
<table>
<tr>
<td rowspan="4" width="20px"> </td>
<td align="right" width="50px">
<asp:Label ID="lblID" runat="server" Text="帐号:"></asp:Label>
</td>
<td colspan="2">
<input id="txtAccount" type="text" runat="server" maxlength="50" />
</td>
<td rowspan="5">
<asp:ImageButton ID="imgBtnLoginLarge" runat="server" ImageUrl="images/login/login_button_login.png" BorderWidth="0px"
ImageAlign="Middle" Width="96px" Height="96px" OnClick="imgbtnLogin_Click" OnClientClick="LockPage();" />
</td>
</tr>
<tr>
<td align="right" width="50px">
<asp:Label ID="lblPassword" runat="server" Text="密码:"></asp:Label>
</td>
<td colspan="2">
<input id="txtPassword" runat="server" type="password" maxlength="19" />
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><a href="WebPage/Account/AccountRegistrationForEyeII.aspx?type=1" onclick="LockPage();">
<%= GetString("DEFAULT_REGISTER_EYEII")%></a> <a href="WebPage/Account/ForgetID.aspx?type=1" onclick="LockPage();">
<%= GetString("DEFAULT_FORGET_ID")%></a></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><a href="WebPage/Account/ForgetPassword.aspx?type=1" onclick="LockPage();">
<%= GetString("DEFAULT_FORGET_PASSWORD")%></a> <a href="WebPage/Account/ResendActivationEmailOrSMS.aspx?type=1" onclick="LockPage();">
<%= GetString("DEFAULT_RESEND_ACTIVATION_EMAIL")%></a></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"><asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label></td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td colspan="4"><img src="images/login/login_desc.png"></td>
<td><a href="WebPage/Account/AccountRegister.aspx?type=1" onclick="LockPage();"><img src="images/login/login_button_register.png"></a></td>
</tr>
</table>
</div>
<div id="loginBoxClose">
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'"><img src="images/login/login_button_close.png"></a>
</div>
protected void imgbtnLogin_Click(object sender, ImageClickEventArgs e)
{
if(string.IsNullOrEmpty(txtAccount.Value)) return;
if(string.IsNullOrEmpty(txtPassword.Value)) return;
hidError.Value = "";
string account = txtAccount.Value.Trim();
string password = txtPassword.Value.Trim(); PCCW_RESPONSE_CODE retType;
SubscriberEntity ret = AccountHelper.Login(PageBase.MasterSessionID, account, password, out retType);
if (ret != null && retType == PCCW_RESPONSE_CODE.SUCCESS)
{
Session["UserId"] = ret.UserId;
Session["LoginEmail"] = account;
Session["Status"] = ret.Status;
Session["ImageId"] = ret.ImageId;
Session["UserFullName"] = ret.FullName;
Session["Stride"] = ret.Stride;
Session["LastLoginTime"] = ret.LastLoginTime.ToString("hh:mm dd/MM/yyyy");
Session["Height"] = ret.Height.ToString();
Session.Timeout = 60; WebUtility.CommonUtility.AddOperationLog(SessionID, OperationLogType.Login, OperatorType.User, CurrentUserId, "", -1, "Login in system...");
Response.Redirect("~/WebPage/MyCareCenter/SummaryView.aspx");
}
else
{
lblMsg.Text = GetString(retType.ToString());
hidError.Value = lblMsg.Text;
}
}
Response.Write("<script language='javascript'>alert('失败'</script>");
看看还关闭吗?
建议:
格式用js验证,数据用ajax验证
我的思路两种:
1,在div层上给个小叉叉图片,当你点击这张的小叉叉时 div隐藏就行
2,加个时间触发器,判断如果时间大于几秒,就隐藏
除非是ajax提交你可以在 成功与否返回值
在前面用ajax接收 然后控制视图