Prevent (Stop) firing Button Click on TextBox TextChanged event in ASP.Net

Last Reply 7 months ago By pandeyism

Posted 7 months ago

i have enable auto postback on textbox ,when i enter value in textbox and press enter then button is also get click .

so i want postack on textbox remain but don't get auto click on button a ,when i insert value in textbox and press enter..

so how it will get done..


Posted 7 months ago

Hi akhter,

Refer below sample.


Name : <asp:TextBox runat="server" ID="txtName" AutoPostBack="true" OnTextChanged="Save" />



protected void Save(object sender, EventArgs e)
    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('" + txtName.Text + "');", true);


Protected Sub Save(ByVal sender As Object, ByVal e As EventArgs)
    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "", "alert('" & txtName.Text & "');", True)
End Sub