Download presentation
Presentation is loading. Please wait.
Published byMilton Cameron Modified over 9 years ago
1
MIS 3200 – Unit 3.2 Page_Load method AutoPostBack property 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
Same code as the previous slide, written with an if else statement: IsPostBack: Usage Example 2
7
The life of a web page 1 st – client requests page 2 nd – server sends page (empty form) 3 rd – responses (filled form) sent to server IsPostback = false IsPostback = true Page_Load runs 4 th – 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; If we want to test a condition, we could say if (condition != true) do something; if (condition == false) //same as != true do something;
9
Page_Load: IsPostBack One more example of the same code written with an if else statement, but this time using the ! (not) operator: Q
10
Think About It! What does AutoPostBack do? How do you test IsPostBack? What does !Page.IsPostBack mean?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.