stighy
stighy

Reputation: 7170

ASP.NET TextBox OnTextChanged event not fire

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

Upvotes: 1

Views: 3937

Answers (3)

Ed B
Ed B

Reputation: 6054

<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.

Upvotes: 1

Greg Olmstead
Greg Olmstead

Reputation: 1551

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

Upvotes: 0

ANC_Michael
ANC_Michael

Reputation: 282

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

Upvotes: 0

Related Questions