what is the alternate event of Textbox.KeyDown of Winform in WebForm in C# asp.net?

前端 未结 3 1902
青春惊慌失措
青春惊慌失措 2021-01-28 08:08

In winfrom applications i can have

textbox1.keydown 

event, but i want to achieve same thing in webform (asp.net), so how can i do that? I need

3条回答
  •  清歌不尽
    2021-01-28 08:58

    In Win Forms you use running machine and interact with it, as you write smth keydown event is fired, but in web forms, once the client side files are sent from server to multiple clients (for ex. stackoverflow.com and its users) no server side event can be fired without javascript. To achieve your goal you I advice you to catch keyUp event in JS and send data by Callback then return data needed from server to client back and handle that data in JS.
    Second Way is to protected void TextBox1_**TextChanged**(object sender, EventArgs e) use this event, but it will refresh the page on every key up.

提交回复
热议问题