简体   繁体   English

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

[英]How to show a error when a modal popup extender is active

  1. I have a modal popup extender 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. 当用户输入新的用户详细信息并尝试输入已经注册的相同电子邮件ID时,我想显示一个错误。

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. 我检查电子邮件是否已被使用,如果已使用,我想弹出错误,但页面仍然停留在顶部,与modalpopupextender相同。 I am not able to do anything after that,. 之后,我无能为力。 How can I display the error. 如何显示错误。

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM