1

I've the following problem: asp.net TextBox server side control, fire onTextChanged only when it loose focus. I would like to fire my server side event each time user press a key. How can i do ? Thanks

stighy
  • 7,260
  • 25
  • 97
  • 157
  • Sure you want to do that?? Could be too expensive from resources point of view. Maybe we can give you a different approach if you give us more details about the feature. – Claudio Redi May 21 '10 at 20:49

3 Answers3

1
<asp:TextBox runat="server" onkeyPress="MyKeyPressEvent;" ID="txtUserName" />

Just add the onkeyPress client event to your textbox.

Then in your JavaScript function "MyKeyPressEvent", call a PageMethod that fires your event method.

Pagemethods are good with onkeyPress, since they have very small Request sizes.

Ed B
  • 6,028
  • 3
  • 26
  • 35
0

Going to have to use ajax since the keypress is a client side event.

ANC_Michael
  • 282
  • 1
  • 4
0

you can use javascript and pagemethods to make it as efficient as possible

use the onkeyup to call a function where you call your pagemethod

http://www.dotnetfunda.com/articles/article454-using-pagemethods-and-json-in-aspnet-ajax.aspx - pagemethods

Greg Olmstead
  • 1,551
  • 10
  • 22