onkeyup event asp.net

前端 未结 1 1577
终归单人心
终归单人心 2021-01-22 06:26

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

Is it possible?

thank you

1条回答
  •  盖世英雄少女心
    2021-01-22 06:46

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

    
        
    
    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

    ``
    

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

    This link might help.

    0 讨论(0)
提交回复
热议问题