Current filter:
                                You should refresh the page.

                                1 Solution

                                Creation Date Importance Sort by

                                The issue occurs because at the moment the startup scriptwindow.onload and document.ready are being executed, our ASP.NET web controls aren't completely initialized on the client side. While certain controls still may function when using this approach, we do not recommend these techniques to work with our controls on the client side when a webpage loads. These approaches are not reliable and may lead to side effects.


                                SOLUTION:

                                1. Our controls provide the client-side ASPxClientControl.Init event that is raised on the client side after the control has been initialized but prior to being displayed in the web browser. You can handle this event to initialize the control on the client side when a page loads.


                                ASP.NET WebForms:

                                [ASPx]
                                <dx:ASPxTextBox ID="TextBox" runat="server" ...> <ClientSideEvents Init="OnTextBoxInit" /> </dx:ASPxTextBox>
                                [JavaScript]
                                function OnTextBoxInit(s, e) { s.SetText('...'); }

                                ASP.NET MVC:

                                [C#]
                                @Html.DevExpress().TextBox(settings => { settings.Name = "TextBox"; settings.Properties.ClientSideEvents.Init = "OnTextBoxInit"; });
                                [VB.NET]
                                @Html.DevExpress().TextBox( Sub(settings) settings.Name = "TextBox" settings.Properties.ClientSideEvents.Init = "OnTextBoxInit" End Sub).GetHtml()
                                [JavaScript]
                                function OnTextBoxInit(s, e) { s.SetText('...'); }

                                2.  It is possible to handle the ASPxClientGlobalEvents.ControlsInitialized / MVCxClientGlobalEvents.ControlsInitialized event to make sure that all DevExpress web controls on the page have been initialized and you can work with them on the client side.


                                ASP.NET WebForms:

                                [ASPx]
                                <dx:ASPxTextBox ID="TextBox" runat="server" ClientInstanceName="TextBox"> </dx:ASPxTextBox> <dx:ASPxGlobalEvents ID="GlobalEvents" runat="server"> <ClientSideEvents ControlsInitialized="OnControlsInitialized" /> </dx:ASPxGlobalEvents>
                                [JavaScript]
                                function OnControlsInitialized(s, e) { TextBox.SetText('...'); }
                                Or:
                                [ASPx]
                                <dx:ASPxTextBox ID="TextBox" runat="server" ClientInstanceName="TextBox"> </dx:ASPxTextBox>
                                [JavaScript]
                                ASPxClientControl.GetControlCollection().ControlsInitialized.AddHandler(function(s, e) { TextBox.SetText('...'); }

                                ASP.NET MVC:

                                [C#]
                                @Html.DevExpress().TextBox(settings => { settings.Name = "TextBox"; }).GetHtml()
                                [VB.NET]
                                @Html.DevExpress().TextBox( Sub(settings) settings.Name = "TextBox" End Sub).GetHtml()
                                [JavaScript]
                                MVCxClientGlobalEvents.AddControlsInitializedEventHandler(function () { TextBox.SetText('...'); });

                                Note that the ASPxClientGlobalEvents.ControlsInitialized  event is raised after each request to the server caused by DevExpress controls. You can use the isCallback parameter to determine if an event is raised as a result of a DevExpress callback. 

                                function OnControlsInitialized(s, e) {
                                if(!e.isCallback) // this change the editor's text on the first load only TextBox.SetText('...'); }


                                See also:
                                K18561: Using jQuery / jQuery UI libraries with DevExpress ASP.NET Controls / MVC Extensions
                                How to perform certain actions after each callback (like MVCxGlobalEvents)

                                • Randall Sell 01.29.2017
                                  This documentation could use a bit of improving... It implies that these are alternatives to using, say jQuery's $(document).ready() but that isn't entirely true. Take for example this...

                                  [JavaScript]
                                  $(document).ready(function () { console.log('Page is Ready via JQuery); });

                                  And stick the GlobalEvents solution on a page:
                                  [ASPx]
                                  <dx:ASPxGlobalEvents ID="globalEvents" runat="server"> <ClientSideEvents ControlsInitialized="PageReady" /> </dx:ASPxGlobalEvents>

                                  [JavaScript]
                                  function PageReady(s, e) { console.log('Page is Ready via DX...); }

                                  Now rev up this page that has an ASPxGridView on it that is doing callbacks (or anything with callbacks).

                                  The documentation does state there is an e.isCallback property but it would be much clearer above if it said the DX equivalent to the jquery Document.Ready() would be more like this:

                                  [JavaScript]
                                  function PageReady(s, e) { if (!e.isCallback) { console.log('Page is Ready via DX... this is the correct jQuery substitution'); } }
                                  cheers,
                                  -randall sell
                                • Artem (DevExpress Support) 01.30.2017

                                  Hi Randall,

                                  Thanks for your feedback. I added a new note to this help article.