Back to Devexpress

ASPxClientCallbackPanel.PerformCallback(parameter) Method

aspnet-js-aspxclientcallbackpanel-dot-performcallback-x28-parameter-x29.md

latest4.7 KB
Original Source

ASPxClientCallbackPanel.PerformCallback(parameter) Method

Sends a callback to the server and generates the server-side ASPxCallbackPanel.Callback event, passing it the specified argument.

Declaration

ts
PerformCallback(
    parameter: string,
    onSuccess?: (arg: string) => void
): void

Parameters

NameTypeDescription
parameterstring

A string value that represents any information that needs to be sent to the server-side ASPxCallbackPanel.Callback event.

| | onSuccess | (arg: string) => void |

A client action to perform if the server round-trip completed successfully.

|

Remarks

Use the PerformCallback method if you need to asynchronously go to the server and perform some server-side processing using AJAX-based callback technology. You can pass the required information which can be collected on the client side as a string of arguments (for instance, in the “Name = Value;” form) via the PerformCallback method’s parameter parameter. The onSuccess parameter allows you to specify a client function that should be executed after the server round-trip completed successfully.

The PerformCallback method posts back to the server using the callback technology, and generates a server-side ASPxCallbackPanel.Callback event. The method’s parameter argument is passed to the ASPxCallbackPanel.Callback event’s handler as the CallbackEventArgsBase.Parameter property. So, the necessary server-side actions can be performed in the event’s handler based upon the values of the arguments which can be obtained by parsing the passed information string.

Note that the necessary actions can be additionally performed on the client side before and after callback processing by using the ASPxClientCallbackPanel.BeginCallback and ASPxClientCallbackPanel.EndCallback client event.

Example

js
function MoveToPage(symbol) {
    MyCallbackPanel.PerformCallback(symbol);
}
aspx
<dx:ASPxCallbackPanel ID="MyCallbackPanel" ClientInstanceName="MyCallbackPanel" runat="server" OnCallback="MyCallbackPanel_Callback">
    <PanelCollection>
        <dx:PanelContent runat="server">
        ...
        </dx:PanelContent>
    </PanelCollection>
</dx:ASPxCallbackPanel>
csharp
public void CreatePager() {
    List<string> alphabet = new List<string>(27);
    int startCharIndex = Convert.ToInt32('A');
    int endChartIndex = Convert.ToInt32('Z');
    for (int i = startCharIndex; i <= endChartIndex; i++)
        alphabet.Add(Convert.ToChar(i).ToString());

    WebControl div = new WebControl(HtmlTextWriterTag.Div);
    PanelPager.Controls.Add(div);
    div.Attributes["class"] = "container";
    foreach (string item in alphabet) {
        HtmlAnchor anchor = new HtmlAnchor();
        div.Controls.Add(anchor);
        anchor.HRef = string.Format("javascript:MoveToPage('{0}')", item);
        anchor.InnerText = item;
        anchor.Attributes["class"] = "anchor";
        if (item == ActivePageSymbol)
            anchor.Attributes["class"] += " active";
    }
}
protected void MyCallbackPanel_Callback(object sender, CallbackEventArgsBase e) {
    ActivePageSymbol = e.Parameter;
    ChangeDataSource();
    CreatePager();
}

Online Demo

See Also

Callbacks

Callback

BeginCallback

EndCallback

Callback Panel

Code Example E4992: How to update multiple ASPxGridViews with one button and hide default update and cancel links

ASPxClientCallbackPanel Class

ASPxClientCallbackPanel Members