I’ve tried implementing this example, but the progress never displays. My page doesn’t include any UpdatePanels or anything, could that be why?
In my page declaration I’ve added:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
Inside the head element I’ve added:
<script src="Scripts/jsUpdateProgress.js" type="text/javascript"></script>
Immediately inside of my form tag I’ve added:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Panel ID="panelUpdateProgress" runat="server" CssClass="updateProgress">
<asp:UpdateProgress runat="server" ID="UpdateProg1" DisplayAfter="0">
<ProgressTemplate>
<div style="position:relative; top:30%; text-align: center;">
<img src="Processing.gif" style="vertical-align: middle" alt="Processing"/>
Processing...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender runat="server" ID="ModalProgress" TargetControlID="panelUpdateProgress" BackgroundCssClass="modalBackground" PopupControlID="panelUpdateProgress"/>
Immediately following end form tag I’ve added:
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endReq);
var ModelProgress = '<%= ModalProgress.ClientID %>';
function beginReq(sender, args) {
$find(ModalProgress).show();
}
function endReq(sender, args) {
$find(ModalProgress).hide();
}
</script>
The button I expect to cause the progress to show:
<asp:Button runat="server" ID="submit" CssClass="multiViewTab" Text="Submit"/>
That button definitely posts back because in my form tag I have:
onsubmit="return validateForm()"
And validateForm runs. validateForm also kicks off the submitForm function if the form is valid, and this contains a JQuery call to AJAX invoking a web service.
Take 2:
Much simpler and pure AJAX, but still doesn’t work.
</form>
<script type='javascript'>
$(document).ready(function() {
$('body').append('<div id="ajaxBusy"><p><img src="Processing.gif"></p></div>');
$('#ajaxBusy').css("updateProgress");
});
$(document).ajaxStart(function () {
$('#ajaxBusy').css("z-index", 2);
}).ajaxStop(function () {
$('#ajaxBusy').css("z-index", -1);
});
I am using z-index because I have a makeshift “wizard” which in essence shows/hides divs using z-index and the progress div wouldn’t show up if I didn’t change the z-index.
According to MSDN, the
UpdateProgressprovides feedback when contents of anUpdatePanelare updated.In short, yes.
Source: UpdateProgress Class
The above link has a nice example.