Two places worth noting in ASP.NET

xiaoxiao2021-03-06  112

The page_load event in the ASPX page in ASP.NET has two strange places, you should remember them:

a. Sometimes Page_Load events will happen multiple times in your ASP.NET page. One possible reason that occurs in this situation is that you set the AUTOEVENWIREUP value of the ASPX page to True. If so, then in "Sub Page_Load (Byval e AS System.EventArgs", it is not necessary. Since Visual Studio.net is automatically You handle this section, you certainly you can set the autoeventwireup value to false.

b. Sometimes it seems that a button clicking the event processing code is not running. Here you should check the Page_Load event to ensure that the code of the load data (the code that binds the data in the drop-down list) only runs when the page is initially loaded, not when the client data is returned. A simple way to check this situation is to add a test for page.ispostback values ​​in your page_load event handler - False means that this is the first time loading and True means that a data return process has occurred. .

转载请注明原文地址:https://www.9cbs.com/read-101731.html

New Post(0)