I am using a textbox inside an update panel and there is textchanged
event for this text box. textchanged
event is firing first time and showing an alert box that email id is present. when i giving email id in text box . but after clicking ok button in alert box again i give email id in text box this time textchanged event not firing.
HTML
<dt>Email:<span style="color: #FF0000;">*</span></dt>
<dd>
<**asp:UpdatePanel ID="UpdatePanel8" runat="server">
<ContentTemplate>
<cc1:OboutTextBox ID="txtEmail" class="input" runat="server"
ontextchanged="txtEmail_TextChanged" AutoPostBack="true"></cc1:OboutTextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtEmail" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>**
</dd>
</dl>
Code Behind:
protected void txtEmail_TextChanged(object sender, EventArgs e)
{
bool flag = false;
if (txtEmail.Text.Trim() != "")
{
string _GlobalDB = Server.MapPath("~//DB//Global.accdb");
flag = Utility.isEmailExist(txtEmail.Text.Trim(), _GlobalDB);
}
if (flag)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "MyScript", @"javascript:alert('Email ID Exist ,Please Use another Email ID.')", true);
txtEmail.Text = "";
txtEmail.Focus();
}
}