开发者

ASP.NET TextBox OnTextChanged event not fire

开发者 https://www.devze.com 2023-01-01 03:18 出处:网络
I\'ve the following problem: asp.net TextBox server side control, fire onTextChanged only when it loose focus.

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 ea开发者_Go百科ch time user press a key. How can i do ? Thanks


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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消