Back to Devexpress

ASPxButton.AutoPostBack Property

aspnet-devexpress-dot-web-dot-aspxbutton-572d5817.md

latest6.8 KB
Original Source

ASPxButton.AutoPostBack Property

Gets or sets a value that specifies whether server-side processing is required to respond to a click on the button control.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(true)]
public bool AutoPostBack { get; set; }
vb
<DefaultValue(True)>
Public Property AutoPostBack As Boolean

Property Value

TypeDefaultDescription
Booleantrue

true, if server-side processing is required, otherwise, false.

|

Remarks

Use the AutoPostBack property to control whether a predefined user action performed over the button (such as changing its checked state, for instance) can be completely processed on the client side by handling an appropriate client-side event (such as the ASPxClientButton.CheckedChanged in this instance), or a round trip to the server is required, so that the action is finally processed on the server side with the help of the corresponding server-side event (such as the ASPxButton.CheckedChanged event).

Note that the available client-side events whose handlers are assigned in a button control are always fired regardless of the AutoPostBack property’s setting. The AutoPostBack property’s value only affects the default value of the ASPxClientProcessingModeEventArgs.processOnServer property which is passed to the editor’s specific client-side events (the AutoPostBack property passes its value to the processOnServer property).

If the AutoPostBack property is set to true, the end-user action is first processed via the corresponding client-side event (if its handler is assigned), and only after that is the server-side processing performed, if it has not been canceled by setting the client-side event’s processOnServer property to false. If the value of the AutoPostBack property is false, a specific user action which has a corresponding server-side event can still be processed on the server side by setting the processOnServer property to true in the client event’s handler.

In such a way, note that server-side events which correspond to specific performed user actions may not be generated in the following two cases:

  • The AutoPostBack property is set to true, but the corresponding client-side event is handled so that the processOnServer property is set to false.
  • The AutoPostBack property is set to false and the corresponding client-side event is not handled, or handled so that the processOnServer property is not changed (is not set to true).

Example

The complete sample project is available in the DevExpress Code Central database at E1120.

javascript
...
function popupControl_Init(s, e) {
    //Synchronize the client variable's value with the confirm dialog checkbox' setting
    dontAskConfirmation = cbDontAsk.GetChecked();
}

function ShowPopup(rowId) {
    //Assign the row's ID value to a specific label within the confirmation dialog, 
    //show the dialog, and set focus to the Yes button
    lbRowId.SetText(rowId);
    popupControl.Show();
    btnYes.Focus();
}

function btnYes_Click(s, e) {
    ClosePopup(true);
}

function btnNo_Click(s, e) {
    ClosePopup(false);
}

function cbDontAsk_CheckedChanged(s, e){
    //Synchronize the client variable's value with the confirm dialog checkbox' 
    //setting, and focus the Yes button
    dontAskConfirmation = cbDontAsk.GetChecked();
    btnYes.Focus();
}
...
aspx
...
<dxrp:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" Width="300px" 
HeaderText="Delete Confirmation" DefaultButton="btnYes">
     <PanelCollection>
         <dxp:PanelContent runat="server">
            <table>
                <tr>
                    <td rowspan="2">
                      <dxe:ASPxImage ID="ASPxImage1" runat="server" ImageUrl="~/Images/img1.png">
                      </dxe:ASPxImage>
                    </td>

                    <td>
                        <dxe:ASPxLabel ID="ASPxLabel1" runat="server" 
                        Text="Are you sure you want to delete this row?">
                        </dxe:ASPxLabel>
                    </td>
                </tr>
                <tr>
                    <td>
                        <dxe:ASPxLabel ID="ASPxLabel2" runat="server" Text="Row ID: " >
                        </dxe:ASPxLabel>    
                        <dxe:ASPxLabel ID="ASPxLabel3" runat="server" 
                        Text="" ClientInstanceName="lbRowId" Font-Bold="True">
                        </dxe:ASPxLabel>     
                    </td>
                </tr>
            </table>
            
 
            <table>
                <tr>
                    <td>
                        <dxe:ASPxCheckBox ID="cbDontAsk" runat="server" 
                        Text="Don't ask confirmation" ClientInstanceName="cbDontAsk">
                            <ClientSideEvents CheckedChanged="cbDontAsk_CheckedChanged" />
                        </dxe:ASPxCheckBox>
                    </td>

                    <td style="width:100%">
                    </td>

                    <td>
                        <dxe:ASPxButton ID="btnYes" runat="server" Text="Yes" Width="50px" 
                             AutoPostBack="False" ClientInstanceName="btnYes">
                            <ClientSideEvents Click="btnYes_Click" />
                        </dxe:ASPxButton>
                    </td>

                    <td>
                        <dxe:ASPxButton ID="btnNo" runat="server" Text="No" 
                             Width="50px" AutoPostBack="False">
                            <ClientSideEvents Click="btnNo_Click" />
                        </dxe:ASPxButton>
                    </td>
                </tr>
            </table>         
         </dxp:PanelContent>
     </PanelCollection>
 </dxrp:ASPxRoundPanel>

See Also

processOnServer

ASPxButton Class

ASPxButton Members

DevExpress.Web Namespace