Skip to main content
All docs
V24.1

Cannot access DevExpress ASP.NET controls on the client

  • 2 minutes to read

Error Description

This error occurs when you try to use the following methods/events:

Solution

This error occurs because DevExpress ASP.NET controls are not completely initialized on the client when you call the startup script, window.onload or document.ready. We do not recommended that you use these APIs with our controls on the client while other controls are still active. These approaches are not reliable and can lead to invalid access to controls on the client.

Use any of the following solutions to resolve the issue:

  1. Handle the client-side Init event to initialize the control on the client when a page loads.

    <dx:ASPxTextBox ID="TextBox" runat="server" ...>  
        <ClientSideEvents Init="OnTextBoxInit" />  
    </dx:ASPxTextBox>  
    
    function OnTextBoxInit(s, e) {  
        s.SetText('...');  
    } 
    
  2. Handle the ControlsInitialized event to make sure that all DevExpress web controls are initialized and accessible on the client.

    <dx:ASPxTextBox ID="TextBox" runat="server" ClientInstanceName="TextBox">  
    </dx:ASPxTextBox>  
    
    <dx:ASPxGlobalEvents ID="GlobalEvents" runat="server">  
        <ClientSideEvents ControlsInitialized="OnControlsInitialized" />  
    </dx:ASPxGlobalEvents>
    
    function OnControlsInitialized(s, e) {  
        TextBox.SetText('...');  
    }  
    

    Or:

    <dx:ASPxTextBox ID="TextBox" runat="server" ClientInstanceName="TextBox">  
    </dx:ASPxTextBox>  
    
    ASPxClientControl.GetControlCollection().ControlsInitialized.AddHandler(function(s, e) {  
        TextBox.SetText('...');  
    }  
    

    Note

    The ControlsInitialized event is raised each time DevExpress controls send a request to the server. You can use the constructor(isCallback) parameter to determine if an event is raised as a result of a DevExpress callback.

See Also