Skip to main content
All docs
V20.2

Common Server-Side Issues

  • 9 minutes to read

The links below describe how to solve common server-side issues:

The target “X” for the callback could not be found or did not implement ICallbackEventHandler

The controller for ASPxUploadProgressHandlerPage.ashx was not found or does not implement IController

Internal Error. Unable to find the X resource in the Y

Response.Redirect cannot be called in a Page callback

Why you cannot download files on callbacks

A primary key field specified using the KeyFieldName property is not found

The “Key expression is undefined” error occurs when you use LinqServerModeDataSource / EntityServerModeDataSource

Data binding methods such as Eval(), XPath(), and Bind() can only be used for a databound control

Could not find control ‘X’ in ControlParameter ‘Y’

“The X has no access to path Y” or “Access to the path X is denied” (Image and File Controls)

The target “X” for the callback could not be found or did not implement ICallbackEventHandler

Error Description:

This error occurs for a parent control or its child controls if the parent control is created at runtime.

Solution:

Follow the steps below when you create a control/WebUserControl at runtime:

  1. Use a control’s constructor or call the LoadControl method with a virtual path to a web user control (*.acsx file) as a parameter to create/load a control or WebUserControl.

  2. Specify the control’s ID property.

    All child controls in a naming container have IDs based on the ID of this container. For example, if an instance of the ASPxDataView with the static ID “ASPxDataView1” is a part of a user control (DataViewUserControl.ascx), its result ID is DataViewUserControl_ASPxDataView1. If a control has no static ID, it is generated dynamically on each request.

  3. Specify the control’s SkinID and EnableTheming properties (optional).

  4. Attach event handlers (if required).

  5. Insert the control into the control hierarchy.

    You should restore the control with the same settings in the Page_Init event when you modify the control hierarchy. For more information, refer to the following online example: How to dynamically load a control that supports callbacks into another control on callback.

  6. Specify the control’s properties.

  7. Bind the control (for data-aware controls).

protected void Page_Init(object sender, EventArgs e) {  
    if (Session["Loaded"] != null) {  
        LoadUserControl();  
    }  
}  

protected void ASPxCallbackPanel1_Callback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) {  
    if (e.Parameter == "Show") {  
        LoadUserControl();  
        Session["Loaded"] = true;  
    }  
    else {  
        UnloadUserControl();  
        Session.Remove("Loaded");  
    }  
}  

protected void LoadUserControl() {  
    Control control = LoadControl("~/DataViewUserControl.ascx");  
    control.ID = "uc";  
    ASPxCallbackPanel1.Controls.Add(control);  
}  

protected void UnloadUserControl() {  
    ASPxCallbackPanel1.Controls.Clear();  
}  
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)  
    If Session("Loaded") IsNot Nothing Then  
        LoadUserControl()  
    End If  
End Sub  

Protected Sub ASPxCallbackPanel1_Callback(ByVal source As Object, ByVal e As DevExpress.Web.ASPxClasses.CallbackEventArgsBase)  
    If e.Parameter = "Show" Then  
        LoadUserControl()  
        Session("Loaded") = True  
    Else  
        UnloadUserControl()  
        Session.Remove("Loaded")  
    End If  
End Sub  

Protected Sub LoadUserControl()  
    Dim control As Control = LoadControl("~/DataViewUserControl.ascx")  
    control.ID = "uc"  
    ASPxCallbackPanel1.Controls.Add(control)  
End Sub  

Protected Sub UnloadUserControl()  
    ASPxCallbackPanel1.Controls.Clear()  
End Sub  

See also: How to create controls dynamically

“The controller for ASPxUploadProgressHandlerPage.ashx was not found or does not implement IController”

Error Description:

This error can occur when you upload a file (in advanced upload mode) for the following controls that use the ASPxUploadProgressHttpHandler:

Solution:

Try one of the following suggestions to overcome this issue:

Internal Error. Unable to find the X resource in the Y

Error Description:

The “Internal error. Unable to find the X resource in the Y” error can occur when you send a request to a page that contains DevExpress ASP.NET controls.

Solution:

  1. Upgrade the DevExpress assemblies as described in the The “Type ‘X’ exists in both assemblies” or “‘X’ is ambiguous in namespace ‘Y’” errors occur topic.

  2. Restart the IIS Web Server (the “iisreset” Windows command).

  3. Remove the “App_Licenses.dll” and “licenses.licx” files.

  4. For IIS v7, use “Classic Pipeline mode” instead of “Integrated”;

  5. Modify an application’s web.config file after deploying and insert a space character to force the IIS Web Server to restart the application.

  6. Register the ASPxHttpHandlerModule in the web.config file as described in the following help topic: How to: Register the ASPxHttpHandlerModule.

For Windows Server 2008 OS:

  • Make sure that all necessary DevExpress assemblies are deployed in a Web application’s Bin folder if a DevExpress product is not installed on the target server.
  • Run the application.
  • Refer to any page with DevExpress ASP.NET controls.
  • Restart the IIS Web Server (the “iisreset” Windows command).
  • Reload the page.

Response.Redirect cannot be called in a Page callback

Error Description:

This error can occur when you use the HttpResponse.Redirect method to navigate to another page on a callback. A callback request expects a response from the same page and a redirect to another page causes the “Response.Redirect cannot be called in a Page callback” error.

Solution:

Use the RedirectOnCallback(String) method to redirect a page to the specified URL when server-side processing is complete:

For v14.2 and earlier (BC2626):

string TARGET_URL = ...;  
if(Page.IsCallback)  
    DevExpress.Web.ASPxWebControl.RedirectOnCallback(TARGET_URL);  
else  
    Response.Redirect(TARGET_URL);  
Dim TARGET_URL As String = ...  
If Page.IsCallback Then  
    DevExpress.Web.ASPxWebControl.RedirectOnCallback(TARGET_URL)  
Else  
    Response.Redirect(TARGET_URL)  
End If  

For v14.1 and older:

string TARGET_URL = ...;  
if(Page.IsCallback)  
    DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(TARGET_URL);  
else  
    Response.Redirect(TARGET_URL);  
Dim TARGET_URL As String = ...  
If Page.IsCallback Then  
    DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback(TARGET_URL)  
Else  
    Response.Redirect(TARGET_URL)  
End If  

Why it is impossible to download files on callbacks

Error Description:

The control clears the callback result and passes the file content to the server response when you download a file on a callback. In this case, client-side objects cannot ascertain the result returned to the browser and the objects’ state becomes broken. Information passed to the response during a callback can corrupt callback data and cause unexpected behavior.

Solution:

To solve this issue, call the export method on a postback, for example, in the server-side ASPxButton.Click event handler. To download a file on a callback, refer to the following online example: How to load a file on a callback sent by the ASPxGridView.

See Also: The Concept of Callbacks

A primary key field specified using the KeyFieldName property is not found

Error Description:

The error can occur when you use the following controls/extensions:

Solution:

Check whether the KeyFieldName property is specified if you use the following ASPxGridView features:

  • Editing.
  • Selection.
  • Master Detail.
  • Endless Paging.

Try one of the following suggestions to overcome this issue:

  1. A data source does not contain a field specified in the KeyFieldName property. Make sure the field name is spelled correctly and in the correct case.

  2. The field is not marked with the “public” keyword or does not have “get”/“set” accessors. You should implement the “get”/“set” accessors for the fields/properties you use;

  3. The data source fields were changed and do not contain this field. You should update the ASPxGridView.KeyFieldName property to reflect the changes made to the data source.

  4. The data source does not contain data records, and ASPxGridView cannot map the schema of data records. Handle the ASPxGridView.DataBinding event and specify the data record type (ForceDataRowType(Type)).

    <dx:ASPxGridView ... OnDataBinding="grid_DataBinding">  
    </dx:ASPxGridView>  
    
    protected void grid_DataBinding(object sender, EventArgs e) {  
        (sender as ASPxGridView).ForceDataRowType(typeof(DATA_RECORD_TYPE_HERE));  
    }  
    
    Protected Sub grid_DataBinding(ByVal sender As Object, ByVal e As EventArgs)  
        (TryCast(sender, ASPxGridView)).ForceDataRowType(GetType(DATA_RECORD_TYPE_HERE))  
    End Sub  
    
  5. The ASPxGridView control is incorrectly bound to its data source.

  6. Set the EnableRowsCache property to false.

The “Key expression is undefined” error occurs when you use LinqServerModeDataSource / EntityServerModeDataSource

Error Description:

This error can occur when the LinqServerModeDataSource / EntityServerModeDataSource data sources cannot automatically recognize the key (unique) column from the TableName or QueryableSource specified at runtime.

Solution:

Do the following to resolve this issue:

protected void LinqServerModeDataSourceInstance_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) {  
    e.KeyExpression = UNIQUE_KEY_COLUMN_NAME;  
}  
Protected Sub LinqServerModeDataSourceInstance_Selecting(ByVal sender As Object, ByVal e As DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs)  
    e.KeyExpression = UNIQUE_KEY_COLUMN_NAME  
End Sub  

Data binding methods such as Eval(), XPath(), and Bind() can only be used for a databound control

Error Description:

This error occurs when you use the Eval(), XPath(), and Bind() methods to bind a DevExpress control to a data source if this control is inside a container (another DevExpress control). For example, if the ASPxGridView contains the ASPxComboBox which you try to bind to a data source.

Solution:

Do the following to solve this issue:

  • Disable a container control’s ViewState.

  • Call the container’s DataBind method in the page/container’s Init event handler.

  • For the ASPxComboBox: Use the DataBindItems() method instead of the DataBind method. For other editors, you do not need the DataBind method at all as the ASPxGridView binds the editors automatically.

  • For the ASPxGridView as a container: Disable its caching mechanism (EnableRowsCache). It is recommended to bind the grid to a data source in the Page_Init event handler if you bind the grid at runtime.

Could not find control ‘X’ in ControlParameter ‘Y’

Error Description:

The error occurs in the following scenario if the ControlParameter.ControlID value is incorrect:

Solution:

Make sure the ControlParameter.ControlID value equals a control’s Control.UniqueID property value.

Use the control’s Init event (How To: Use the Init/Load event handler) to find its unique ID and assign it to the ControlParameter.ControlID property.

<dx:ASPxComboBox ID="ASPxComboBox1" runat="server" DataSourceID="AccessDataSource1"  
    ValueType="System.Int32" ValueField="CategoryID" 
    TextField="CategoryName" OnInit="ASPxComboBox1_Init">  
    ...
</dx:ASPxComboBox>
protected void ASPxComboBox1_Init(object sender, EventArgs e) {  
    ASPxComboBox control = (ASPxComboBox)sender;  
    System.Diagnostics.Debug.WriteLine(control.UniqueID); // It can be ASPxPanel1$ASPxComboBox1, ASPxGridView1$Title$ASPxComboBox1, etc.  
}  

“The X has no access to path Y” or “Access to the path X is denied” for File and Image Controls

Error Description:

The errors occur when you use the following controls:

Solution:

Use the following API to specify permissions for file (IO) operations:

You can use the code below in the Page_Init event handler to check if the specified Web Server’s directory has permissions for file operations:

using System.IO;  
...  

protected void Page_Init(object sender, EventArgs e) {  
    string dirVirtualPath = "~/TestDir";  
    string dirPhysicalPath = MapPath(dirVirtualPath);  
    if(!Directory.Exists(dirPhysicalPath)) {  
        Directory.CreateDirectory(dirPhysicalPath);  
    }  

    string fileName = "TestFile.txt";  
    string fileFullPath = Path.Combine(dirPhysicalPath, fileName);  

    File.WriteAllText(fileFullPath, "File Content Here...");  

}  
Imports System.IO  
...  

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)  
    Dim dirVirtualPath As String = "~/TestDir"  
    Dim dirPhysicalPath As String = MapPath(dirVirtualPath)  
    If (Not Directory.Exists(dirPhysicalPath)) Then  
        Directory.CreateDirectory(dirPhysicalPath)  
    End If  

    Dim fileName As String = "TestFile.txt"  
    Dim fileFullPath As String = Path.Combine(dirPhysicalPath, fileName)  

    File.WriteAllText(fileFullPath, "File Content Here...")  
End Sub