gpt4 book ai didi

jquery - 'panelName' 的 DefaultButton 必须是 IButtonControl 类型的控件的 ID

转载 作者:行者123 更新时间:2023-12-03 23:03:31 26 4
gpt4 key购买 nike

我正在 ASP.NET 上开发一个网站,并使用 bootstrap 进行设计。我正在使用模态淡入淡出类(如弹出窗口)供用户登录。

这是我的代码:

<div class="modal fade" id="login" role="dialog">
<asp:Panel ID="AZloginPanel" runat="server">
<div class="modal-dialog">
<div class="modal-content">
<div class="form-horizontal">
<div class="modal-header">
<h4>Login</h4>
</div>
<div class="modal-body">
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
<LayoutTemplate>
<span class="failureNotification">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"
ValidationGroup="LoginUserValidationGroup" />
<div class="accountInfo">
<fieldset class="login">
<div class="form-group">
<asp:Label ID="UserNameLabel" CssClass="col-lg-2 control-label" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
<div class="col-lg-10">
<asp:TextBox ID="UserName" runat="server" CssClass="form-control" placeholder="Username"></asp:TextBox>
</div>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</div>
<div class="form-group">
<asp:Label ID="PasswordLabel" CssClass="col-lg-2 control-label" runat="server" AssociatedControlID="Password">Password:</asp:Label>
<div class="col-lg-10">
<asp:TextBox ID="Password" runat="server" CssClass="form-control" placeholder="Password" TextMode="Password"></asp:TextBox>
</div>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</div>
<p>
<asp:CheckBox ID="RememberMe" runat="server" />
<asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
</p>
</fieldset>
<div class="modal-footer">
<p class="pull-left">
<asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false" NavigateUrl="~/Account/Register.aspx">Register</asp:HyperLink>if you don't have an account.
</p>
<asp:Button ID="CloseModal" runat="server" CssClass="btn btn-info" CommandName="Close" Text="Close" />
<asp:Button ID="LoginButton" runat="server" CssClass="btn btn-primary" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup" />
</div>
</div>
</LayoutTemplate>
</asp:Login>
</div>
</div>
</div>
</div>
</asp:Panel>
</div>

当我在 AZloginPanel 面板中设置 DefaultButton="LoginButton" 时,出现以下错误:

The DefaultButton of 'AZloginPanel' must be the ID of a control of type IButtonControl.

我迷路了,我已经尝试了一切,但似乎已经走进了死胡同。

有什么想法吗?

最佳答案

问题是 asp:login控件修改其子级的 id,因此 asp:panel控件不知道在哪里寻找新的 DefaultButton id。

这是重现该问题的简化版本:

<asp:Panel ID="AZloginPanel" runat="server" <b>DefaultButton="LoginButton"</b>>
<asp:Login ID="LoginUser" runat="server" >
<LayoutTemplate>
<asp:TextBox ID="UserName" runat="server" />
<asp:TextBox ID="Password" runat="server" TextMode="Password" />
<asp:Button ID="LoginButton" runat="server" Text="Log In" />
</LayoutTemplate>
</asp:Login>
</asp:Panel>

如果您想使用DefaultButton for a LoginControl ,您可以执行以下两种操作之一:

1。将面板嵌套在登录控件内:

<asp:Login ID="LoginUser" runat="server" >
<LayoutTemplate>
<b><asp:Panel runat="server" DefaultButton="LoginButton"></b>
<asp:TextBox ID="UserName" runat="server" />
<asp:TextBox ID="Password" runat="server" TextMode="Password" />
<asp:Button ID="LoginButton" runat="server" Text="Log In" />
<b></asp:Panel></b>
</LayoutTemplate>
</asp:Login>

2。使用 LoginControlID 构建 ID,然后使用 $ 构建 ID,然后使用按钮 ID:

<asp:Panel ID="AZloginPnl" runat="server" <b>DefaultButton="LoginUser$LoginButton"</b>>
<asp:Login ID="<b>LoginUser</b>" runat="server" >
<LayoutTemplate>
<asp:TextBox ID="UserName" runat="server" />
<asp:TextBox ID="Password" runat="server" TextMode="Password" />
<asp:Button ID="<b>LoginButton</b>" runat="server" Text="Log In" />
</LayoutTemplate>
</asp:Login>
</asp:Panel>

关于jquery - 'panelName' 的 DefaultButton 必须是 IButtonControl 类型的控件的 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24672312/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com