当模式弹出扩展器处于活动状态时如何显示错误

发布于 2024-12-07 15:59:43 字数 417 浏览 0 评论 0原文

我有一个 ModalPopupExtender 来创建新用户。当用户输入新的用户详细信息并尝试输入已注册的相同电子邮件 ID 时,我想显示错误。

创建用户:

  if (emailcount != 0)
            {
                
                Page.ClientScript.RegisterStartupScript(GetType(), "UserDialogScript", 

"alert(\"User already exists!\");", true);
            }

我检查电子邮件是否已使用,如果已使用,我想弹出错误,但页面保持静止,ModalPopupExtender位于顶部。在那之后我什么也做不了。我怎样才能显示错误?

I have a ModalPopupExtender to create new users. When the user enters the new user details and tries to enter the same email Id which is already registered then I want to show a error.

Create user:

  if (emailcount != 0)
            {
                
                Page.ClientScript.RegisterStartupScript(GetType(), "UserDialogScript", 

"alert(\"User already exists!\");", true);
            }

I check whether the email is already used, if it is used I want to pop up the error but the page stays still with the ModalPopupExtender on the top. I am not able to do anything after that. How can I display the error?

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

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

发布评论

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

评论(1

却一份温柔 2024-12-14 15:59:43

我会为此使用不同的方法。在您的模态弹出扩展程序中,尝试如下操作:

<asp:UpdatePanel ID="pnlUserDetails" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="txtEmail" runat="server" OnTextChanged="txtEmail_OnTextChanged" AutoPostBack="true"></asp:TextBox>
        <asp:Label ID="lblEmailMessage" runat="server" Text="Already exists!" Visible="false" /> 
    </ContentTemplate>
</asp:UpdatePanel>

在代码隐藏中:

protected void txtEmail_TextChanged(object sender, EventArgs e)
{
    //check for matching email address and show label if match is found
    lblEmailMessage.Visible = FindMatchingEmailAddress(txtEmail.Text.Trim());    

    //clear the email input if a match is found??
    txtEmail.Text = String.Empty;
}

I would use a different approach for this. In your modal popup extender, try something like this:

<asp:UpdatePanel ID="pnlUserDetails" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="txtEmail" runat="server" OnTextChanged="txtEmail_OnTextChanged" AutoPostBack="true"></asp:TextBox>
        <asp:Label ID="lblEmailMessage" runat="server" Text="Already exists!" Visible="false" /> 
    </ContentTemplate>
</asp:UpdatePanel>

In the code-behind:

protected void txtEmail_TextChanged(object sender, EventArgs e)
{
    //check for matching email address and show label if match is found
    lblEmailMessage.Visible = FindMatchingEmailAddress(txtEmail.Text.Trim());    

    //clear the email input if a match is found??
    txtEmail.Text = String.Empty;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文