ASP.NET Server Controls
Controls:
- Properties
- Methods
- Events
Property:
A Property is an attribute of control which mainly has its impact on the look of the control.
Eg: Forecolor, BorderColor, Font Size, Font Family, etc
Method:
A Method is an action that has to be performed.
Eg: Focus( )
Event:
An Event is a time period that tells when an action has to be performed.
Eg: OnClick, TextChanged, CheckedChanged
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
PostBack:
A webpage sending the request back to itself is called as PostBack.
The page has a series of events and those events will fire every time the page is loaded i.e either in the first request of the page or the postback request of the page.
this.IsPostBack — This will be false if it is First Request and True if it is next or PostBack Request.
PostBack Submission:
In a PostBack all the data that is associated with the form and its controls will be submitted to the page on the server.
Who is capable of Submitting a page to the Server?
— By default, Button Control is designed for submitting a page to the server, whereas other controls such as TextBox, CheckBox, RadioButton, DropDownList, etc are also capable of submitting a page to the server provided their AutoPostBack property value is set True, by default it is False.
Cached Events:
When we define any event handlers to control which are not capable of submitting the page to the server, the events fire based on the client action gets stored in the cached memory and fires after the page is submitted to the server.
The Sequence of Events:
- Page load Event fired.
- Cached Event fired.
- Post Back Event fired.
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
Post Back v/s Cross Post Back:
Post Back — a page calling back itself and submitting data to itself is called as PostBack.
Cross PostBack — a page calling and submitting data to another page is called Cross PostBack.
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
Server.Transfer v/s Response.Redirect
Server.Transfer —
- The transfer from one page to another page happens on the server only and it is unknown to the browser.
2. Faster because it happens on Server.
3. Can transfer to only .aspx pages.
4. Previous page object is available in the memory and can be accessed on the new page.
5. Can transfer only to pages that are present in the sites of the current webserver.
Response.Redirect —
- The transfer from one page to another page happens from the browser so the browser is aware of the page from where the output is coming from.
- Slower as there is an additional round trip involved.
- Can transfer to either .aspx or .html
- Previous page object is not available because the request is going from the browser.
- Can transfer to pages that are present under the sites of the current web server or even an external web server.