gizgok
gizgok

Reputation: 7649

Fire Textbox.TextChange event without a button click

I want to call Textbox.OnTextChange event without having to click a submit button or any button. How can I do this? As I enter text in the textbox, I want the ontextchange event to fire.

I would elaborate this further.I've a function for validating my entry in textbox which I'm calling ontextchange property.Now this function should be called without me changing focus from my textbox.

Upvotes: 0

Views: 4297

Answers (3)

Jerzakie
Jerzakie

Reputation: 115

If you want a postback: You want to use the onkeypress or onkeyup javascript event to run the __doPostBack javascript method. __doPostPack has some parameters you will need to look up on msdn

Otherwise just use the onkeypress or onkeyup javascript event to do whatever else it is you need with javascript.

Upvotes: 0

lincolnk
lincolnk

Reputation: 11238

you can set AutoPostBack to true on the textbox control. when the client side change event fires (when the focus changes from the textbox to something else), the page will do a postback automatically.

Upvotes: 2

Shoban
Shoban

Reputation: 23016

You can use onkeypress , onkeyup and onkeydown events for this.

http://www.w3schools.com/tags/tag_input.asp

Example :

  <asp:TextBox ID="TextBox1" runat="server" onKeyPress="javascript:alert('Key Pressed');"></asp:TextBox>

Upvotes: 1

Related Questions