C# 在asp.net中使用进度条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11754477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using progress bar in asp.net
提问by Answer_42
i used the examples given in this link
我使用了此链接中给出的示例
here are my code for the .aspx page
这是我的 .aspx 页面代码
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jqueryui.css"
rel="stylesheet" type="text/css" />
<script type="text/jscript" src="http://ajax.googleapis.com/ajax/libs/jquery1.5/jquery .min.js"></script>
<script type="text/jscript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/jscript">
$(document).ready(function() {
$("#progressbar").progressbar({ value: 37 });
});
</script>
</asp:Content>
and the div for the progress bar is this one
进度条的 div 就是这个
<div style="margin-left: 10px; margin-right: 10px;" id="progressbar"> </div>
i tried to follow the instructions given on the source page but nothing worked. can you tell me what i am missing here? thanx in advance. (Fixed this part.i made a mistake at placing my contntentplaceholder)
我试图按照源页面上给出的说明进行操作,但没有任何效果。你能告诉我我在这里缺少什么吗?提前谢谢。(修复了这一部分。我在放置内容占位符时犯了一个错误)
EDIT: how can i change the value in a way so that it animates when i press a button.... the button's code in the page is as follows :
编辑:我如何以某种方式更改值,以便在我按下按钮时动画......页面中按钮的代码如下:
<asp:Button ID="btnConfirm" CssClass="button" SkinID="Common" runat="server"Text="Confirm"OnClick="btnConfirm_Click" />
采纳答案by nunespascal
Try this:
尝试这个:
<script type="text/jscript">
jQuery(document).ready(function() {
jQuery("#progressbar").progressbar({ value: 37 });
});
</script>
$is also used by asp.net for its own clientside javascript.
$也被 asp.net 用于它自己的客户端 javascript。
Consider us jQuery.noConflict()
You could encapsulate your jQuery code like this:
你可以像这样封装你的 jQuery 代码:
jQuery.noConflict();
(function($) {
$(function() {
$(document).ready(function() {
$("#progressbar").progressbar({ value: 37 });
// more code using $ as alias to jQuery
});
})(jQuery);
EDIT:To update the value surround your content above and the button with an UpdatePanel.
编辑:要更新围绕您上面的内容和带有UpdatePanel.
Refer how to use UpdatePanels
Assign the Progress percentage to an asp literal.
将进度百分比分配给 asp 文字。
jQuery.noConflict();
(function($) {
$(function() {
$(document).ready(function() {
$("#progressbar").progressbar({ value: <asp:Literal runat="server" ID="ProgressPercentage" /> });
// more code using $ as alias to jQuery
});
})(jQuery);
On button click
点击按钮
ProgressPercentage.Text = progress.ToString();

