创建用户:
if (emailcount != 0)
{
Page.ClientScript.RegisterStartupScript(GetType(), "UserDialogScript",
"alert(\"User already exists!\");", true);
}
我检查电子邮件是否已被使用,如果已使用我想弹出错误但页面保持静止,顶部有modalpopupextender。之后我无能为力。如何显示错误。
答案 0 :(得分:0)
我会使用不同的方法。在你的模态弹出扩展器中,尝试这样的事情:
<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;
}