What's the difference between AutoPostBack=True
and AutoPostBack=False
?
Autopostback is the mechanism by which the page will be posted back to the server automatically based on some events in the web controls. In some of the web controls, the property called auto post back, if set to true, will send the request to the server when an event happens in the control.
A postback is initiated by the browser, and reloads the whole page, usually when a control on the page (e.g. a button) is changed. With some controls (e.g. Checkboxes), you choose if changing the control should result in a postback. This property is called AutoPostback.
The AutoPostBack property is used to set or return whether or not an automatic post back occurs when the user selects an item in a list control. If this property is set to TRUE the automatic post back is enabled, otherwise FALSE.
Any Control that has its AutoPostBack Property set to true is connected to the _doPostBack() function using the onclick or onchange attributes. These attributes indicate what action should Browser take in response to the Client-Side javascript events onclick and onchange.
Taken from http://www.dotnetspider.com/resources/189-AutoPostBack-What-How-works.aspx:
Autopostback
is the mechanism by which the page will be posted back to the server automatically based on some events in the web controls. In some of the web controls, the property called auto post back, if set to true, will send the request to the server when an event happens in the control.Whenever we set the autopostback attribute to true on any of the controls, the .NET framework will automatically insert a few lines of code into the HTML generated to implement this functionality.
- A JavaScript method with name __doPostBack (eventtarget, eventargument)
- Two hidden variables with name __EVENTTARGET and __EVENTARGUMENT
- OnChange JavaScript event to the control
AutoPostBack = true
permits control to post back to the server. It is associated with an Event.
Example:
<asp:DropDownList id="id" runat="server" AutoPostBack="true" OnSelectIndexChanged="..."/>
The aspx page with the above drop down list does not need an asp:button
to do the post back. When you change an option in the drop down list, the page gets posted back to the server.
Default value of AutoPostBack
on control is false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With