Two notable places in the ASP.net program

Source: Internet
Author: User
Tags visual studio
Asp.net| Program

The Page_Load event for an ASPX page in asp.net has two strange places to remember:

A. Sometimes Page_Load events occur more than once in your ASP.net page. One possible reason for this happening is that you set the Autoevenwireup value of the ASPX page to True. If so, it is not necessary to add the "System.EventArgs Handles" line after the Sub Page_Load (ByVal Sender as System.object,byval e as MyBase.Load). Since Visual Studio.NET can automatically handle this part for you, you can of course set the AutoEventWireup value to False.

B. Sometimes it's like a button click event handling code is not running. Here you should check the Page_Load event to ensure that any code that loads the data (for example, the code that binds the data in the Drop-down list) runs only when the page is initially loaded, not when the client data is returned later. A simple way to check this is to add a test to the Page.IsPostBack value in your Page_Load event handler-false means that this is the first time the page is loaded and true means that a data return process has occurred.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.