开发者

onkeyup event asp.net

Hi how can i register and call a server side event for onkeyup event in asp.net textbox.

Is it possible?

thank you开发者_C百科


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜