Click here to Skip to main content
15,917,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox with textchanged function but after that textchange function. It automatically trigger the button. How can I not trigger the button?

Is there any keypress function in textchange?

This is the textchange function

VB
Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles txtPalleteNo.TextChanged
if txtPalleteNo.text = ""
ELSE
//DO CODE HERE

End If
        txtPalleteNo.Text = ""
        txtPalleteNo.Focus()




This is the Button that is being triggered after the textchange.

VB
Protected Sub btnAccept_Click(sender As Object, e As EventArgs) Handles btnAccept.Click

       drpShipNo.Enabled = False
       btnShipment.Enabled = True
       btnAccept.Enabled = False
       txtPalleteNo.Enabled = False

end sub
Posted
Updated 28-Apr-15 15:46pm
v2
Comments
Can you please share some code?
NekoNao 28-Apr-15 21:47pm    
i added the code
What about the aspx? How have you defined those controls?

1 solution

I guess you are calling some code to trigger the button.
By default, button click won't occur on keypress in a textbox.

Regarding keypress and keychange, both are independent events that fire when the textbox text changes -
Keypress[^]
Textchanged[^]
 
Share this answer
 
Comments
Karthik_Mahalingam 28-Apr-15 5:47am    
yes,you are rite

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900