文本更改事件未触发
我在更新面板内使用文本框,并且该文本框有 textchanged
事件。 textchanged
事件首次触发,并显示一个警告框,表明存在电子邮件 ID。当我在文本框中提供电子邮件 ID 时。但再次单击警报框中的“确定”按钮后,我在文本框中给出了电子邮件 ID,这次 textchanged 事件未触发。
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>
隐藏代码:
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();
}
}
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();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论