0

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.

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Will it fire when I make a entry in the textbox..or will it need a button click or some kind of other action
It will fire when your cursor leaves the textbox with AutoPostBack
If i want to do without changing focus from the textbox,is there a way to do that
1

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>

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.