开发者

Is there an ASP.NET textarea onkeyup equivalent?

I've got an asp:TextArea that I would like to do some processing (filtering a list) as the user types. I'm sure I could do the filtering within a javascript function called via the onkeyup event, but I'd prefer to do it in my VB.NET code.

Is it possible to do such a thing, or should I just stick with the Javascript? If the latter, could you please explain why?

开发者_C百科Thanks!


Stick to the javascript, for one simple reason: postback will lag.

Think about how fast you type. And think about how fast your server responds when a postback is submitted. Now, what will happen when the user types "Hello, world!" in two seconds? He'll get to "Hell" and then the browser will load the postback response. And the user will be back at "H". If every time your user tries to type something you delete a couple of letters, he'll hate your interface.

Doing it with javascript isn't harder than doing it with VB.Net - use jQuery or some other javascript library that makes your life easy, and you'll be filtering that list without keeping your users waiting.


I'd stick with Javascript. otherwise you are going to be posting back to the server each time the user enters a letter which is going to be slow and awkward from a usability perspective.


Depends on the number of possible Users. Imagine that plenty of users are entering text simultaneously. This would overstress your Server bandwith/RAM/CPU. But if thats not an issue you could use Ajax and make an Async Postback on the Textbox' client event OnChange.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜