Page class Introduction

Source: Internet
Author: User

Page class Introduction: code page separation mode: Partial indicates that the definition of this class is incomplete, and some are in other folders.
Page lifecycle: (1) page request: Before the page lifecycle starts, Asp. net will determine whether to analyze and compile the page (to start the page lifecycle ).
(2) Start: At the start stage, page properties such as request and response will be set. In this phase, the page will also confirm whether the request is a sending request or a new request, and set the ispostback attribute. In addition, the uiclture attribute of the page is set during the start phase.

(3) page initialization: During page initialization, you can use controls on the page and set the uniqueid attribute for each control. In addition, any topic will be applied to the page. If the current request is a send-back request, the send-back data has not been loaded, and the control property value has not been restored to the value in the view State.
(4) loading: during the loading period, if a request is sent back, the control attributes are added using the information restored from the view status and control status.
(5) Verification: During verification, the validate method of all validators controls is called, which sets the isvalid attributes of each validators control and the page.
(6) event processing: if the request is a development request, all event processing programs will be called.
(7) Rendering: During the rendering, the view State is saved to the page, and each control is called on the page to output the outputstream provided to the page's response attribute.
(8) uninstall: the page is displayed completely. When the page is sent to the client and you are about to discard the page, the call is uninstalled. In this case, the page properties (such as response and resquest) are uninstalled and cleared.
Page events: (1) Start With page_prelnit
(2) page_init Initialization
(3) Load page_load
(4) controlevents
(5) page_prerender
(6) page_unload uninstall
Web stateless: A web application is stateless. Every time you request a new webpage or refresh a Web server, a new instance of the current page is created.
Ispostback attribute: The page class has an ispostback attribute that indicates whether the current page is loaded for the first time or responds to a server event of a control on the page.
Validaterequest attribute: used to check whether the input is potentially dangerous. The default value is true;
How to output the Javascript script on the page: (1) response. Write () method: But it will destroy the XHTML structure.
(2) registerclientscriptblock () method: close to the <form> mark.
(3) registerstartupscript () method: close to the </form> mark.
The page class has a clientscript attribute: (1) It is an instance of clientscriptmanager.
(2) registerclientscriptblock (): registers client scripts with the page object.
(3) registerstartupscript (): registers the startup script with the page object.
Example:
Response. Write ("<script language = 'javascript '> alert ('000000'); <SCRIPT> ");
String scriptstring = "<script language = 'javascript '> alert ('000000'); <SCRIPT> ";
Clinetscriptmanage CSM = page. clientscript;
CSM. registerclientscriptblock (this. GetType (), "Sss", scriptstring, false );
CSM. registerstartupscript (this. GetType (), "Sss", scriptstring, false );
 

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.