Hello
The ASPxCallback component doesn't update any area in the html representation of a page, but has a client CallbackComplete event.
If you want to use the ASPxCallback you need to modify your code in the following manner.
UserControl ASPX code:
<table cellpadding="0" cellspacing="0" style="width: 100%;">
<tr>
<td>
<dxe:ASPxLabel ID="ASPxLabel1" runat="server" Text="UserControl 1 has been loaded successfully"
ClientInstanceName="lbl">
</dxe:ASPxLabel>
</td>
</tr>
<tr>
<td style="padding-top: 10px; height: 54px;" align="center">
<dxe:ASPxButton ID="okButton1" runat="server" Text="Ok" AutoPostBack="false">
<ClientSideEvents Click="function(s, e) { callback1.SendCallback(); } " />
</dxe:ASPxButton>
</td>
</tr>
</table>
<dxcb:ASPxCallback ID="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback"
ClientInstanceName="callback1">
<ClientSideEvents CallbackComplete="function(s, e) {
lbl.SetText(e.result);
}" />
</dxcb:ASPxCallback>
UserControl C# code:
protected void ASPxCallback1_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) {
e.Result = "Callback works!";
}
Page C# code:
protected void Page_Load(object sender, EventArgs e) {
if(Session["UC_Loaded"] != null && Request.Params["__CALLBACKID"] != "clbCallback") {
Control resControl = Page.LoadControl(string.Format(UserControlPathTemplate, Session["UC_Loaded"]));
if(resControl != null)
pcPopup.Controls.Add(resControl);
}
}
protected void OnCallback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) {
Control resControl = null;
if(!string.IsNullOrEmpty(e.Parameter)) {
resControl = Page.LoadControl(string.Format(UserControlPathTemplate, e.Parameter));
Session["UC_Loaded"] = e.Parameter;
}
if(resControl != null) {
pcPopup.Controls.Add(resControl);
e.Result = ASPxCallback.GetRenderResult(resControl);
}
}
Page JS code:
function ShowPopup(userControlID) {
popup.SetHeaderText("UserCotnrol " + userControlID);
popup.SetContentHTML("Loading...");
popup.Show();
// We cannot use cache in this case
callback.SendCallback(userControlID);
}
But I would recommend that you use our ASPxCallbackPanel control for this purpose.
UserControl ASPX code:
<table cellpadding="0" cellspacing="0" style="width: 100%;">
<tr>
<td>
<dxcp:ASPxCallbackPanel ID="ASPxCallbackPanel1" runat="server" ClientInstanceName="cbp"
Width="200px" OnCallback="ASPxCallbackPanel1_Callback">
<PanelCollection>
<dxp:PanelContent runat="server">
<dxe:ASPxLabel ID="ASPxLabel1" runat="server" Text="UserControl 1 has been loaded successfully"
ClientInstanceName="lbl">
</dxe:ASPxLabel>
</dxp:PanelContent>
</PanelCollection>
</dxcp:ASPxCallbackPanel>
</td>
</tr>
<tr>
<td style="padding-top: 10px; height: 54px;" align="center">
<dxe:ASPxButton ID="okButton1" runat="server" Text="Ok" AutoPostBack="false">
<ClientSideEvents Click="function(s, e) { cbp.PerformCallback(); } " />
</dxe:ASPxButton>
</td>
</tr>
</table>
UserControl C# code:
protected void ASPxCallbackPanel1_Callback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) {
ASPxLabel1.Text = "Callback works!";
}
Page C# code:
protected void Page_Load(object sender, EventArgs e) {
if(Session["UC_Loaded"] != null && Request.Params["__CALLBACKID"] != "clbCallback") {
Control resControl = Page.LoadControl(string.Format(UserControlPathTemplate, Session["Loaded"]));
if(resControl != null)
pcPopup.Controls.Add(resControl);
}
}
protected void OnCallback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e) {
Control resControl = null;
if(!string.IsNullOrEmpty(e.Parameter)) {
resControl = Page.LoadControl(string.Format(UserControlPathTemplate, e.Parameter));
Session["UC_Loaded"] = e.Parameter;
}
if(resControl != null) {
pcPopup.Controls.Add(resControl);
e.Result = ASPxCallback.GetRenderResult(resControl);
}
}
Page JS code:
function ShowPopup(userControlID) {
popup.SetHeaderText("UserCotnrol " + userControlID);
popup.SetContentHTML("Loading...");
popup.Show();
// We cannot use cache in this case
callback.SendCallback(userControlID);
}
Thanks, Roman
R&D, .Net Team, DevExpress
PS. If you wish to receive direct assistance from our Support Team, use
Support Center.