1024programmer Asp.Net In ASP.NET WebForm, other events will be triggered when the TextBox input box is entered, how to deal with it?

In ASP.NET WebForm, other events will be triggered when the TextBox input box is entered, how to deal with it?

ASP.NET WebForm will trigger other events when entering the TextBox input box, how to  Processing?
In ASP.NET WebForm, pressing the Enter key on the keyboard in the page will automatically trigger some events, but this is not the effect we want, we can set it to cancel it, so how to deal with it?

1. TextBox will trigger other events when entering the input box, how to solve it?

In ASP.NET WebForm, pressing the Enter key on the keyboard in the page will automatically trigger certain events, but this is not the effect we want, we can set it to cancel it, how to deal with it?

Foreground code:

  • Name:

Set the code in Page_Load in the background:

Code example:

//Set the button to trigger any event by pressing Enter
 txtCategoryName.Attributes["onkeydown"] = "if(event.keyCode==13){return false;}";
 

2. How to specify the event of the button when the carriage return of the TextBox is triggered?

In ASP.NET WebForm, if you press the Enter key on the keyboard on the page, you need to customize settings to trigger certain events, such as pressing the Enter key to automatically perform query operations.

Code example:

 protected override void OnInitComplete(EventArgs e)
         {
             base.OnInitComplete(e);
             // TextBox carriage return triggers custom event method
             this.txtCategoryName.TextChanged += new EventHandler(btnOrder_Click);
         }
 

Original link: https://www.cnblogs.com/kimiliucn/p/17589948.html

Copyright statement: This article is an original article, and the copyright belongs to [Watermelon Programmer]. Please indicate the source for reprinting. If you have any questions, please consult by private message.
Original link: https://www.cnblogs.com/kimiliucn/p/17589948.html

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/in-asp-net-webform-other-events-will-be-triggered-when-the-textbox-input-box-is-entered-how-to-deal-with-it/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索