1 / 10

MIS 3200 – Unit 3.2

MIS 3200 – Unit 3.2. Page_Load method AutoPostBack property of controls IsPostBack method of the Page object Understanding web page life cycle. Page_Load Method. Handles the page_load event It occurs when Page is loaded for the first time

chiku
Télécharger la présentation

MIS 3200 – Unit 3.2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MIS 3200 – Unit 3.2 • Page_Load method • AutoPostBackproperty of controls • IsPostBack method of the Page object • Understanding web page life cycle

  2. Page_Load Method • Handles the page_load event • It occurs when • Page is loaded for the first time • a web control with AutoPostBack = true is run • Sends contents of the page back to the server

  3. AutoPostBack Property • Is a Boolean property of a web control • causes page information to be sent back to server • tells the server that the page is “posting back” • i.e. Page.IsPostback gets set to TRUE • Example: in U3L2 you set the AutoPostBack = true • As a result, whenever it was changed, it “posted back” to the server, and • Told the server that this was not first request about that page , but was a post back.

  4. IsPostBack • Is a Boolean property of the Page • Used inside the Page_Load method • e.g. Page.IsPostBack • FALSE: when page is loaded for the first time • TRUE: when the user interacts with the page • E.g. clicks a button • E.g. changes a radio button that has AutoPostBack=TRUE

  5. IsPostBack: Usage Example 1 Knowing if the IsPostBack property of the Page object is true or false can allow you to determine which messages should be displayed:

  6. IsPostBack: Usage Example 2 Same code as the previous slide, written with an if else statement:

  7. The life of a web page 1st – client requests page IsPostback= false Page_Load runs Page_Load runs 2nd – server sends page (empty form) 3rd – responses (filled form) sent to server IsPostback= true 4th– server sends page (results)

  8. Equal or not! In Unit 3.1, we looked at relational operators and were introduced to the idea of saying something was not equal by using the ! (exclamation mark) If we want to test a condition, we could say if (condition != true) do something; if (condition == false) //same as != true do something;

  9. Q Page_Load: IsPostBack One more example of the same code written with an if else statement, but this time using the ! (not) operator:

  10. Think About It! • What does AutoPostBack do? • How do you test IsPostBack? • What does !Page.IsPostBack mean?

More Related