How to: Update an External Control During a Callback

  • 4 minutes to read

Since ASPxCardView works during callbacks by default, it is not possible to update an external control (that is not a child control of the callback owner) on the server side.

The following topic describes this limitation in detail: Callbacks.

This example covers both the ASPxCardView’s JSProperties feature (which allows you to pass a value from the server to the client) and the client-side ASPxClientCardView.EndCallback event (which is raised each time a callback is executed successfully). It is possible to use the ASPxCardView control’s client-side capabilities to set a JSProperty on the server, get it on the EndCallback, and change the “target” control.

View Example

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register assembly="DevExpress.Web.v15.1, Version=, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web" tagprefix="dx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <dx:aspxlabel ID="ASPxLabel1" runat="server" ClientInstanceName="clientLabel">
    <dx:ASPxCardView ID="ASPxCardView1" runat="server" AutoGenerateColumns="false" DataSourceID="AccessDataSource1" KeyFieldName="CategoryID" OnCardUpdated="ASPxCardView1_CardUpdated">
        <clientsideevents EndCallback="function(s, e) {
            if (s.cpIsUpdated != '') {
                clientLabel.SetText('The category '+s.cpIsUpdated+' is updated successfully');
                clientLabel.GetMainElement().style.backgroundColor = 'green';
                clientLabel.GetMainElement().style.color = 'white';
            else {
         }" />
            <dx:CardViewColumn FieldName="CategoryID" ReadOnly="true" />
            <dx:CardViewColumn FieldName="CategoryName" ReadOnly="true"/>
            <dx:CardViewColumn FieldName="Description" ReadOnly="true"/>
                <dx:CardViewCommandLayoutItem ShowEditButton="true" HorizontalAlign="Right" />
                <dx:CardViewColumnLayoutItem ColumnName="CategoryID" />
                <dx:CardViewColumnLayoutItem ColumnName="CategoryName" />
                <dx:CardViewColumnLayoutItem ColumnName="Description" />
                <dx:EditModeCommandLayoutItem HorizontalAlign="Right" />
    <asp:accessdatasource ID="AccessDataSource1" runat="server" 
        DeleteCommand="DELETE FROM [Categories] WHERE [CategoryID] = ?" 
        InsertCommand="INSERT INTO [Categories] ([CategoryID], [CategoryName], [Description], [Picture]) VALUES (?, ?, ?, ?)" 
        SelectCommand="SELECT * FROM [Categories]" 
        UpdateCommand="UPDATE [Categories] SET [CategoryName] = ?, [Description] = ?, [Picture] = ? WHERE [CategoryID] = ?">
            <asp:parameter Name="CategoryID" Type="Int32" />
            <asp:parameter Name="CategoryName" Type="String" />
            <asp:parameter Name="Description" Type="String" />
            <asp:parameter Name="Picture" Type="Object" />
            <asp:parameter Name="CategoryID" Type="Int32" />
            <asp:parameter Name="CategoryID" Type="Int32" />
            <asp:parameter Name="CategoryName" Type="String" />
            <asp:parameter Name="Description" Type="String" />
            <asp:parameter Name="Picture" Type="Object" />