我在 jQuery 对话框中设置了登录控件。但是,登录按钮在对话框中不起作用,当我删除对话框时它工作正常。用户名和密码上有一些字段验证器可以进行一些 javascript 验证,所以我认为可能存在一些冲突,但我无法弄清楚。有任何想法吗?
这是我的标记:
<div id="loginBox">
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
<LayoutTemplate>
<span class="failureNotification">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<div class="accountInfo" style="float: left; width: 220px;">
<fieldset class="login">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
<asp:TextBox ID="UserName" runat="server" CssClass="textEntry" Width="190"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
CssClass="red-text" ErrorMessage="User Name is required." ToolTip="User Name is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" >Password:</asp:Label>
<asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password" Width="190"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
CssClass="red-text" ErrorMessage="Password is required." ToolTip="Password is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator><br/>
<asp:CheckBox ID="RememberMe" runat="server" style="display: inline-block;" />
<asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" style="display: inline-block; font-weight: normal;">Remember Me</asp:Label>
</fieldset>
<p class="submitButton">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup" />
</p>
</div>
<div style="float: left; width: 170px; padding-top: 15px;">
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="red-text" ValidationGroup="LoginUserValidationGroup" />
</div>
<div class="clearfix"></div>
</LayoutTemplate>
</asp:Login>
</div>
jQuery:
<script type="text/javascript">
$(document).ready(function () {
// Dialog
$('#loginBox').dialog({
autoOpen: true,
width: 420,
modal: true,
draggable: false,
title: "<h2 style='margin-bottom: 0px;'>Log In</h2>",
closeOnEscape: false,
open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
resizable: false,
show: { effect: "fade", duration: 1500 }
});
})
</script>
文件后面的代码中没有任何内容。我注意到当我在页面呈现后检查登录按钮时,它上面有这个:
<input type="submit" name="ctl00$mainbody$LoginUser$LoginButton" value="Log In" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$mainbody$LoginUser$LoginButton", "", true, "LoginUserValidationGroup", "", false, false))" id="mainbody_LoginUser_LoginButton">
因此,我猜测 javascript 在出现在对话框中时由于某种原因没有运行,但我不确定如何修复它。