我希望我的登录控件在用户登录时显示“正在加载...” gif。
为了让我的登录控件显示我想要的方式,我将其转换为模板。然后我按照这里看到的指导:here和here在回发期间显示gif。
我现在有几个问题。当我尝试提交无效登录时,页面会按预期执行:它显示加载 gif,然后在确定登录无效后 gif 消失。但是现在即使我输入了有效的登录名,它也会说它无效。我在编辑登录模板时是否搞砸了?
我的另一个问题是我有风格化的“keepLogged”复选框。样式是由 JQuery 在头部添加的。当您第一次进入页面时它会正确显示,但在回发之后,当登录显示无效时,不会应用样式并且它是一个正常的复选框。
这是代码:
<script>
$(document).ready(function () {
$("input[type=checkbox]").addClass("mini-switch");
});
</script>
<form id="form1" runat="server" class="form with-margin" name="login-form">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="updateLogin" runat="server" DefaultButton="mainLogin$LoginButton">
<ContentTemplate>
<asp:Login ID="mainLogin" runat="server" RenderOuterTable="False" onloginerror="mainLogin_LoginError">
<LayoutTemplate>
<div class="block-header">Please login</div>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server"
ValidationGroup="mainLogin" CssClass="message error no-margin"
DisplayMode="List"/>
<input type="hidden" name="a" id="a" value="send">
<p class="inline-small-label">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"><span class="big">User name</span></asp:Label>
<asp:TextBox ID="UserName" runat="server" CssClass='full-width'></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="mainLogin"
Display="None" />
</p>
<p class="inline-small-label">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"><span class="big">Password</span></asp:Label>
<asp:TextBox ID="Password" runat="server" TextMode="Password" CssClass='full-width'></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="mainLogin"
Display="None" />
</p>
<asp:Button ID="LoginButton" runat="server" CommandName="Login"
Text="Log In" type="button"
ValidationGroup="mainLogin" onclick="LoginButton_Click" CSSClass='button float-right'/>
<p class="input-height">
<asp:CheckBox ID="keepLogged" runat="server" Checked="True"/>
<asp:Label ID="Label1" runat="server" Text="Keep me logged in" AssociatedControlID="keepLogged" CssClass="inline"></asp:Label>
</p>
</LayoutTemplate>
</asp:Login>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img alt="" src="images/lock.gif" /> <strong>Logging In...</strong>
</ProgressTemplate>
</asp:UpdateProgress>
</form>
谢谢你的帮助。