onkeyup event asp.net

一个人想着一个人 提交于 2019-12-01 22:51:53

TextBox Web control doesn't provide onkeyXXX events instead subscribe to OnTextChanged event;

<asp:TextBox ID='Textbox1' runat='server' OnTextChanged='HandleTextbox1OnTextChanged'>
    </asp:TextBox>

public void HandleTextbox1OnTextChanged(Object sender, EventArgs e)
    {

    }

But you can provide onkeyXXX behavior from client-side.

You can add client-side handler like :

Textbox1.Attributes.Add("onkeyup", String.Format("onKeyUp({0})", TextBox1.ID));

And in the page

`<script language='javascript' type='text/javascript'>
   function onKeyUp(id) { //do something; } 
</script>`

Also you could use PageMethods to make a call to server-side web methods (static methods) from javascript functions.

This link might help.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!