只是想知道是否有人看到C#.net应用程序的任何可用进度条。我的应用程序需要大约20-60秒才能加载,我很乐意在用户等待时向用户显示进度条。我看到了this one,但示例网站似乎没有用,这不会激发信心。
答案 0 :(得分:4)
您可以使用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>
如果你想要动画,你需要做的就是将动画.gif弹出到'ProgressTemplate'。
答案 1 :(得分:1)
我会查看这篇博文 - 似乎是一个很好的方法。我自己没有测试过......
http://mattberseth.com/blog/2008/05/aspnet_ajax_progress_bar_contr.html
答案 2 :(得分:1)
在aspx页面中你需要写这个,我已经添加了你自己需要定义的某些CSS类,这个代码可以帮助你明确功能
<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>
定义一个函数,比如说ProgressIndicator如下
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();
}
};
给出的示例包含带有模态的进度指示器,i:当进度指示器正在运行时,它禁用在屏幕上执行的其他操作。如果不需要,可以删除模态部件。