C#: How to make pressing enter in a text box trigger a button, yet still allow shortcuts such as “Ctrl+A” to get through?

后端 未结 5 1085
抹茶落季
抹茶落季 2021-02-03 22:01

Sorry for the long title, but I couldn\'t think of another way to put it.

I have this:

    private void textBoxToSubmit_KeyDown(object sender, KeyEventAr         


        
5条回答
  •  耶瑟儿~
    2021-02-03 22:30

    You do not need any client side code if doing this is ASP.NET. The example below is a boostrap input box with a search button with an fontawesome icon.

    You will see that in place of using a regular < div > tag with a class of "input-group" I have used a asp:Panel. The DefaultButton property set to the id of my button, does the trick.

    In example below, after typing something in the input textbox, you just hit enter and that will result in a submit.

    
    
    
        
    
    

提交回复
热议问题