Know of a good page load progressbar for my ASP.net application?
-
03-07-2019 - |
Question
Just wondering if anyone has seen any usable progress bar for C# .net apps. My app takes about 20-60 secs to load and I would love to show users a progress bar while they wait. I saw this one but the sample site doesn't seem to work which doesn't inspire confidence.
Solution
You can use the AJAX UpdateProgress control.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdateProgress runat="server" id="PageUpdateProgress">
<ProgressTemplate>
Loading...
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel runat="server" id="Panel">
<ContentTemplate>
<asp:Button runat="server" id="UpdateButton" onclick="UpdateButton_Click" text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
If you want animation, all you need to do is pop an animated .gif into the 'ProgressTemplate'.
OTHER TIPS
I would look into this blog post - seems like a good way to do it. I haven't tested it myself...
http://mattberseth.com/blog/2008/05/aspnet_ajax_progress_bar_contr.html
In aspx page you need to write this,I have added certain CSS class which you yourself need to define, functinality wise this code will help you
<asp:Panel ID="ProgressIndicatorPanel" runat="server" Style="display: none" CssClass="modalPopup">
<div id="ProgressDiv" class="progressStyle">
<ul class="ProgressStyleTable" style="list-style:none;height:60px">
<li style="position:static;float:left;margin-top:0.5em;margin-left:0.5em">
<asp:Image ID="ProgressImage" runat="server" SkinID="ProgressImage" />
</li>
<li style="position:static;float:left;margin-top:0.5em;margin-left:0.5em;margin-right:0.5em">
<span id="ProgressTextTableCell"> Loading, please wait... </span>
</li>
</ul>
</div>
</asp:Panel>
Define a function say ProgressIndicator as follows
var ProgressIndicator = function (progPrefix) {
var divId = 'ProgressDiv';
var textId = 'ProgressTextTableCell';
var progressCss = "progressStyle";
if (progPrefix != null) {
divId = progPrefix + divId;
textId = progPrefix + textId;
}
this.Start = function (textString) {
if (textString) {
$('#' + textId).text(textString);
}
else {
$('#' + textId).text('Loading, please wait...');
}
this.Center();
//$('#' + divId).show();
var modalPopupBehavior = $find('ProgressModalPopupBehaviour');
if (modalPopupBehavior != null) modalPopupBehavior.show();
}
this.Center = function () {
var viewportWidth = jQuery(window).width();
var viewportHeight = jQuery(window).height();
var progressDiv = $("#" + divId);
var elWidth = progressDiv.width();
var elHeight = progressDiv.height();
progressDiv.css({ top: ((viewportHeight / 2) - (elHeight / 2)) + $(window).scrollTop(),
left: ((viewportWidth / 2) - (elWidth / 2)) + $(window).scrollLeft(), visibility: 'visible'
});
}
this.Stop = function () {
//$("#" + divId).hide();
var modalPopupBehavior = $find('ProgressModalPopupBehaviour');
if (modalPopupBehavior != null) modalPopupBehavior.hide();
}
};
The example given conatins a Progress Indicator with Modal ,i:e when progress Indicator is running it disables other operations to be performed on the screen.You can remove the Modal part if you doesnt need it .