Click here to Skip to main content
15,845,436 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

In it is required to use a Progress Bar <dx: ASPxProgressBar ID="Form_ProgressBar"> that allows to represent asynchronously the duration of a background process on the Server side executed by the Fcn_AppConexionesSelectedIndexChanged() function and that also updates the <dx: ASPxNavBar ID="Form_NavBar"> control on the Client Side.

On the server side it is required to be able to use a Session variable to Store and Retrieve Information. The web page does more things that requires Session variables.

In the code that serves as an example, we have a control <asp: DropDownList ID="Form_Conexiones" runat="server" AutoPostBack="false" OnChange="javascript: Fcn_ProgressBar_In Start ('ProgressBar_In Start');"/>
with an "OnChange" event that executes a javascript function Fcn_ProgressBar_In Start() that starts the 2 Callback processes:

-Callback 1. Activates a function on the Server Side Fcn_AppConexionesSelectedIndexChanged() that Executes a Long-Term Process and that Updates the information of a <dx: ASPxNavBar ID="Form_NavBar"> control.
-Callback 2. Activates a function on the Server Side Fcn_ProgressBar_Callback_jQuery() that Retrieves the Position in the long-term process and returns to the Client part to activate it in the <dx: ASPxProgressBar ID="Form_ProgressBar"> control.

<pre>// Client side.
 // ------------
<script language="javascript" type="text/javascript"> 
 // Function that Executes Actions according to the variable "action". 
function Fcn_ProgressBar_Acciones_(accion)
      switch (accion)
      {  case 'ProgressBar_Iniciar':
                 Form_ProgressBar_CallbackPanel.PerformCallback();  // Callback of Long Term Process.
                 Fcn_ProgressBar_PerformCallback_jQuery();                // Callback of the Process that Recovers the Position of the Progress Bar in the Long-Term Process .

 // Function that Recovers the Position of the Progress Bar in the Long Duration Process. Callback to function  Fcn_ProgressBar_Callback_jQuery().
function Fcn_ProgressBar_PerformCallback_jQuery()
            type: "POST",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            url: "busqueda.aspx/Fcn_ProgressBar_Callback_jQuery",
            success: function(success)
            {   var Position = success.d;
                Form_ProgressBar.SetPosition(Position);        // ProgressBar. Update Position .
                Fcn_ProgressBar_PerformCallback_jQuery();  // New Callback to the Fcn_ProgressBar_Callback_jQuery() function that Retrieves the Position of the Progress Bar in the Long Duration Process .

 // ProgressBar.
<dx:ASPxProgressBar ID="Form_ProgressBar" runat="server"/>

// Long-Term Process Updating Control  <dx:ASPxNavBar ID="Form_NavBar">.  Callback Panel.
<dx:ASPxCallbackPanel ID="Form_ProgressBar_CallbackPanel" runat="server" OnCallback="Fcn_AppConexionesSelectedIndexChanged">
            <asp:updatepanel ID="Form_UpdatePanel1" runat="server">
                         // Control that Activates Callback of the Long Duration Process through the event "OnChange".
                       <asp:DropDownList ID="Form_Conexiones" runat="server" AutoPostBack="false" OnChange="javascript:Fcn_ProgressBar_Iniciar('ProgressBar_Iniciar');"/>
                        // Control that will be updated with New Information in the Long-Term Process.
                         <dx:ASPxNavBar ID="Form_NavBar" runat="server"/>

// CodeBehind. Function that Returns the Position of the Progress Bar in the Long Term Process. Ej.:0-100.
public static Position;
public static string Fcn_ProgressBar_Callback_jQuery()
{  return Position; }

// CodeBehind. Function that Performs the Long-Term Process and Updates the Control <dx:ASPxNavBar ID="Form_NavBar">
protected void Fcn_AppConexionesSelectedIndexChanged(object sender, DevExpress.Web.CallbackEventArgsBase e)
{   // ProgressBar. Position.
    for (Position = 1; Position <= 100; Position++)
    { ... // Update control information <dx:ASPxNavBar ID="Form_NavBar">.

It is necessary that the two Callbacks run simultaneously. At this time, while the Long Duration Process Callback is executing,
the Callback that Retrieves the Position in the long-term process and that returns to the Client part to activate it in the <dx: ASPxProgressBar ID="Form_ProgressBar"> control remains waiting the first callback ends.


Excerpt retrieved following the second Link:
Simultaneous session state and callbacks.
-Concurrent callbacks don't work if you use session state. Blocks parallel execution and forces parallel requests to run one after another because access to state of the ASP.NET session is unique per session. For this reason, the above example (How to display progress information about server-side callback processing) does not work if you use session state. To work around this problem, turn off session state at the page or project level. Ex: <% @ Page Language = "C #" CodeFile = "Default.aspx.cs" Inherits = "_ Default" EnableSessionState = "False"%>
When session state is disabled, it is no longer possible to use session variables.

You can use the following alternatives:
-Application state, The application state stores variables that can be accessed by all users of an ASP.NET application.
-Profile properties, Profile properties preserve user values ​​in a data store without expiring.
-ASP.NET caching, ASP.NET caching stores values ​​in memory that is available to all ASP.NET applications.
-Query string and fields, The query string and fields in an HTML form that are available from an HTTP request.

CURRENT SITUATION: At this point I have been stopped waiting to find a viable solution.

What I have tried:

in internet in the links of the information
Updated 7-Jan-22 19:56pm
Member 14890678 8-Jan-22 1:25am    
If I use a thread in the Fcn_AppConexionesSelectedIndexChanged () function of the long-term process, it ends immediately and the second Callback begins, but then the <dx: aspxnavbar="" id="Form_NavBar"> control It does not actualize.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900