Parallel UpdateProgress display

U

Urs Widmer

Hi there,

I have a problem using the UpdateProgress Panel out of the ASP.NET Ajax
Components. For ensure that no Ajax-Call cancels another running Ajax-Call I
use a Queue System, so that all calls will be done. (The Queuing JS you will
find on the bottom of this entry)

If I have multiple UpdatePanel's in my webform and each of them has its own
UpdateProgress there is just shown the UpdateProgress of the Item I've last
clicked on. But mybe there are one or more other processes also running at
this moment and I want them to display their UpdateProgress too.

Has somebody an idea how to solve that problem?

My ASP.NET Source:
-----------------------
<form id="form1" runat="server">

<div>


<asp:ScriptManager ID="ScriptManager1" runat="server">

<Scripts>

<asp:ScriptReference Path="~/ajaxPageRequest.js" />

</Scripts>

</asp:ScriptManager>

<script type="text/javascript">

PageRequestManagerEx.init();

</script>

<br />

<br />

<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">

<ProgressTemplate>

Panel 1 in progress...

</ProgressTemplate>

</asp:UpdateProgress>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<asp:Label ID="Label1" runat="server" Text="Label">Panel 1</asp:Label>

<br />

<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />

</Triggers>

</asp:UpdatePanel>

<br />

<br />

<asp:UpdateProgress ID="UpdateProgress2" runat="server"

AssociatedUpdatePanelID="UpdatePanel2" DynamicLayout="False">

<ProgressTemplate>

Panel 2 in progress...

</ProgressTemplate>

</asp:UpdateProgress>

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">

<ContentTemplate>

<asp:Label ID="Label2" runat="server" Text="Label">Panel 2</asp:Label>

<br />

<asp:Button ID="Button2" runat="server" Text="Button"
onclick="Button2_Click" />

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />

</Triggers>

</asp:UpdatePanel>


</div>

</form>

Code Behind:
--------------
using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class AjaxTest : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void Button1_Click(object sender, EventArgs e)

{

System.Threading.Thread.Sleep(2000);

this.Label1.Text = DateTime.Now.ToString();

}

protected void Button2_Click(object sender, EventArgs e)

{

System.Threading.Thread.Sleep(2000);

this.Label2.Text = DateTime.Now.ToString();

}

}




Queue-JavaScript File (ajaxPageRequest.js):
------------------------------------------
var PageRequestManagerEx =

{

_initialized: false,

init: function() {

if (!PageRequestManagerEx._initialized) {

var _prm = Sys.WebForms.PageRequestManager.getInstance();

var _callQueue = new Array();

var _executingElement = null;

_prm = Sys.WebForms.PageRequestManager.getInstance();

_prm.add_initializeRequest(initializeRequest);

_prm.add_endRequest(endRequest);

PageRequestManagerEx._initialized = true;

}

function initializeRequest(sender, args) {

if (_prm.get_isInAsyncPostBack()) {

//if we are here that means there already a call pending.

//Get the element which cause the postback

var postBackElement = args.get_postBackElement();

//We need to check this otherwise it will abort the request which we made
from the

//end request

if (_executingElement != postBackElement) {

// Grab the event argument value

var evArg = $get("__EVENTARGUMENT").value;

//Does not match which means it is another control

//which request the update, so cancel it temporary and

//add it in the call queue

args.set_cancel(true);

Array.enqueue(_callQueue, new Array(postBackElement, evArg));

}

//Reset it as we are done with our matching

_executingElement = null;

}

}

function endRequest(sender, args) {

//Check if we have a pending call

if (_callQueue.length > 0) {

//Get the first item from the call queue and setting it

//as current executing item

_executingElement = Array.dequeue(_callQueue);

var _element = _executingElement[0];

var _eventArg = _executingElement[1];

//Now Post the from which will also fire the initializeRequest

_prm._doPostBack(_element.id, _eventArg);

}

}

}

}

if (typeof (Sys) != 'undefined') {

Sys.Application.notifyScriptLoaded();

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top