UpdatePanel 中的登录控件触发外部验证控件 - ASP.net

发布于 2024-07-19 18:55:15 字数 6446 浏览 4 评论 0原文

我试图在同一页面上同时拥有登录视图和创建用户向导。 我想用更新面板分隔这两个事件。 然而,我遇到的问题是,当我尝试登录时,createuserwizard 的验证触发器似乎被触发,即使它位于登录控件更新面板之外。

有人可以解释一下吗? 代码如下:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" >
</asp:ScriptManager>

        <asp:UpdatePanel ID="LoginUpdatePanel" runat="server" UpdateMode="Always">
        <ContentTemplate>
        <div id="login">
            <asp:LoginView ID="LoginView1" runat="server">
            <LoggedInTemplate>
            <asp:LoginName ID="LoginName1" runat="server" /> - <asp:LoginStatus ID="LoginStatus1" LogoutText="LOGOUT" runat="server" />
            </LoggedInTemplate>
            <AnonymousTemplate>
            <asp:Login ID="BizLogin" runat="server" VisibleWhenLoggedIn="false" OnAuthenticate="Login1_Authenticate" >
                <LayoutTemplate>
                    <asp:Label ID="Label1" AssociatedControlID="UserName" runat="server">Email</asp:Label>
                    <asp:TextBox runat="server" ID="UserName" CssClass="loginFields"></asp:TextBox>
                    <asp:requiredfieldvalidator id="UserNameRequired" runat="server" ControlToValidate="UserName" Text="*"></asp:requiredfieldvalidator>
                    <asp:Label ID="Label2" AssociatedControlID="Password" runat="server">Password</asp:Label>
                    <asp:TextBox runat="server" ID="Password" CssClass="loginFields" TextMode="Password"></asp:TextBox>
                    <asp:requiredfieldvalidator id="PasswordRequired" runat="server" ControlToValidate="Password" Text="*"></asp:requiredfieldvalidator>
                    <asp:Button id="loginButton" CommandName="Login" runat="server" Text="Login"></asp:Button></button>
                </LayoutTemplate>
            </asp:Login>
            </AnonymousTemplate>
            </asp:LoginView>
        </div>
        </ContentTemplate>
        </asp:UpdatePanel>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>
        <asp:CreateUserWizard id="CreateUserWizard1" Runat="server" OnCreatingUser="OnCreatingUser" LoginCreatedUser="true" OnContinueButtonClick="ContinueButtonClick">
            <WizardSteps>
                <asp:CreateUserWizardStep ID="CreateUserWizard1Step" runat="server">
                    <ContentTemplate>
                        <table>
                        <tr>
                        <th>User Information</th>
                        </tr>
                        <tr>
                        <td>First Name:</td>
                        <td>
                        <asp:TextBox ID="FirstName" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="FirstNameRequired" runat="server" ControlToValidate="FirstName"
                        ErrorMessage="First Name is required." ToolTip="First Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                        </td>
                        </tr>
                        <tr>
                        <td>Last Name:</td>
                        <td>
                        <asp:TextBox ID="LastName" runat="server"></asp:TextBox>
                        </td>
                        </tr>
                        <tr>
                        <td>Email:</td>
                        <td>
                        <asp:TextBox runat="server" ID="UserName" />
                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName"
                        ErrorMessage="Username is required." />
                        </td>
                        </tr>
                        <tr>
                        <td>Password:</td>
                        <td>
                        <asp:TextBox runat="server" ID="Password" TextMode="Password" />
                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password"
                        ErrorMessage="Password is required." />
                        </td>
                        </tr>
                        <tr>
                        <td>Confirm Password:</td>
                        <td>
                        <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword"
                        ErrorMessage="Confirm Password is required." />
                        </td>
                        </tr>
                        <tr>
                        <td></td>
                        <td>
                        <asp:TextBox runat="server" ID="Email" Visible="false"/>
                        </td>
                        </tr>
                        <tr>
                        <td colspan="2">
                        <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                        ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator>
                        </td>
                        </tr>
                        <tr>
                        <td colspan="2">
                        <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                        </td>
                        </tr>
                        </table>
                        </ContentTemplate>
                </asp:CreateUserWizardStep>
            </WizardSteps>
        </asp:CreateUserWizard>
        </ContentTemplate>
        </asp:UpdatePanel>


</div>
</form>

I am trying to have both a loginview and createuserwizard on the same page. I want to separate the two events with an updatepanel. The problem I am experiencing however is that when I attempt to login, the validation triggers for the createuserwizard appear to be fired, even though it is outside the login controls updatepanel.

Can someone explain this? Code below:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" >
</asp:ScriptManager>

        <asp:UpdatePanel ID="LoginUpdatePanel" runat="server" UpdateMode="Always">
        <ContentTemplate>
        <div id="login">
            <asp:LoginView ID="LoginView1" runat="server">
            <LoggedInTemplate>
            <asp:LoginName ID="LoginName1" runat="server" /> - <asp:LoginStatus ID="LoginStatus1" LogoutText="LOGOUT" runat="server" />
            </LoggedInTemplate>
            <AnonymousTemplate>
            <asp:Login ID="BizLogin" runat="server" VisibleWhenLoggedIn="false" OnAuthenticate="Login1_Authenticate" >
                <LayoutTemplate>
                    <asp:Label ID="Label1" AssociatedControlID="UserName" runat="server">Email</asp:Label>
                    <asp:TextBox runat="server" ID="UserName" CssClass="loginFields"></asp:TextBox>
                    <asp:requiredfieldvalidator id="UserNameRequired" runat="server" ControlToValidate="UserName" Text="*"></asp:requiredfieldvalidator>
                    <asp:Label ID="Label2" AssociatedControlID="Password" runat="server">Password</asp:Label>
                    <asp:TextBox runat="server" ID="Password" CssClass="loginFields" TextMode="Password"></asp:TextBox>
                    <asp:requiredfieldvalidator id="PasswordRequired" runat="server" ControlToValidate="Password" Text="*"></asp:requiredfieldvalidator>
                    <asp:Button id="loginButton" CommandName="Login" runat="server" Text="Login"></asp:Button></button>
                </LayoutTemplate>
            </asp:Login>
            </AnonymousTemplate>
            </asp:LoginView>
        </div>
        </ContentTemplate>
        </asp:UpdatePanel>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
        <ContentTemplate>
        <asp:CreateUserWizard id="CreateUserWizard1" Runat="server" OnCreatingUser="OnCreatingUser" LoginCreatedUser="true" OnContinueButtonClick="ContinueButtonClick">
            <WizardSteps>
                <asp:CreateUserWizardStep ID="CreateUserWizard1Step" runat="server">
                    <ContentTemplate>
                        <table>
                        <tr>
                        <th>User Information</th>
                        </tr>
                        <tr>
                        <td>First Name:</td>
                        <td>
                        <asp:TextBox ID="FirstName" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="FirstNameRequired" runat="server" ControlToValidate="FirstName"
                        ErrorMessage="First Name is required." ToolTip="First Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                        </td>
                        </tr>
                        <tr>
                        <td>Last Name:</td>
                        <td>
                        <asp:TextBox ID="LastName" runat="server"></asp:TextBox>
                        </td>
                        </tr>
                        <tr>
                        <td>Email:</td>
                        <td>
                        <asp:TextBox runat="server" ID="UserName" />
                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName"
                        ErrorMessage="Username is required." />
                        </td>
                        </tr>
                        <tr>
                        <td>Password:</td>
                        <td>
                        <asp:TextBox runat="server" ID="Password" TextMode="Password" />
                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password"
                        ErrorMessage="Password is required." />
                        </td>
                        </tr>
                        <tr>
                        <td>Confirm Password:</td>
                        <td>
                        <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
                        <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword"
                        ErrorMessage="Confirm Password is required." />
                        </td>
                        </tr>
                        <tr>
                        <td></td>
                        <td>
                        <asp:TextBox runat="server" ID="Email" Visible="false"/>
                        </td>
                        </tr>
                        <tr>
                        <td colspan="2">
                        <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                        ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator>
                        </td>
                        </tr>
                        <tr>
                        <td colspan="2">
                        <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                        </td>
                        </tr>
                        </table>
                        </ContentTemplate>
                </asp:CreateUserWizardStep>
            </WizardSteps>
        </asp:CreateUserWizard>
        </ContentTemplate>
        </asp:UpdatePanel>


</div>
</form>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文