In this article I will explain with an example, the difference between AutoPostBack True and AutoPostBack False in ASP.Net.
AutoPostBack property allows controls which cannot submit the Form (PostBack) on their own and hence ASP.Net has provided a feature using which controls like DropDownList, CheckBoxList, RadioButtonList, etc. can perform PostBack.
 
How does AutoPostBack work?
AutoPostBack property uses JavaScript and HiddenFields for performing PostBack. There are two HiddenFields __EVENTTARGET and __EVENTARGUMENT and a JavaScript function __doPostBack.
Difference between AutoPostBack True and AutoPostBack False in ASP.Net
 
Example of AutoPostBack using DropDownList
Now I will illustrate, how AutoPostBack works using an example of ASP.Net DropDownList control.
 
 
HTML Markup
The HTML Markup consists of an ASP.Net DropDownList specified with OnSelectedIndexChanged event handler and AutoPostBack property set to True.
<asp:DropDownList ID="ddlFruits" runat="server" AutoPostBack = "true" OnSelectedIndexChanged = "OnSelectedIndexChanged">
    <asp:ListItem Text="Mango" Value="1" />
    <asp:ListItem Text="Apple" Value="2" />
    <asp:ListItem Text="Banana" Value="3" />
    <asp:ListItem Text="Guava" Value="4" />
    <asp:ListItem Text="Orange" Value="5" />
</asp:DropDownList>
 
 
The SelectedIndexChanged event of ASP.Net DropDownList
When an item is changed in ASP.Net DropDownList, the following OnSelectedIndexChanged event handler is executed.
Inside the event handler, the selected Text and Value of the DropDownList Selected Item is fetched and displayed using JavaScript Alert message box.
C#
protected void OnSelectedIndexChanged(object sender, EventArgs e)
{
    string message = ddlFruits.SelectedItem.Text + " - " + ddlFruits.SelectedItem.Value;
    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + message + "');", true);
}
 
VB.Net
Protected Sub OnSelectedIndexChanged(sender As Object, e As EventArgs)
    Dim message As String = ddlFruits.SelectedItem.Text & " - " & ddlFruits.SelectedItem.Value
    ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('" & message & "');", True)
End Sub
 
 
Screenshot
Difference between AutoPostBack True and AutoPostBack False in ASP.Net
 
 
Demo
 
 
Downloads