Click here to Skip to main content
Click here to Skip to main content

Use jQuery Progressbar To Display The Percentage Of User Info

By , 26 Dec 2011
 

The original: http://zoyobar.blogspot.com/2011/12/use-jquery-progressbar-to-display-user.html

Introduction/Catalog

Due to the limited time, synchronization cannot be guaranteed in more than one blog article, at the following address you can view up-to-date content, please understand:

http://zoyobar.blogspot.com/2011/12/use-jquery-progressbar-to-display-user.html

Please download the sample code at the section JQueryElement Demo Download of Download JQueryElement, the directory is /progressbar/Default.aspx.

This article explains the function and the use of Progressbar , the catalog is as follows:

* Prepare
* Progress
* Appendix: The Percentage Of Information

Prepare

Be sure that you have got the latest version of JQueryElement at the section JQueryElement.dll Download of Download JQueryElement

Use the following statements to reference namespace:

<%@ Register Assembly="zoyobar.shared.panzer.JQueryElement"
 Namespace="zoyobar.shared.panzer.ui.jqueryui"
 TagPrefix="je" %>
<%@ Register Assembly="zoyobar.shared.panzer.JQueryElement"
 Namespace="zoyobar.shared.panzer.web.jqueryui"
 TagPrefix="je" %>
  

In addition to the namespace, you need to reference the jQueryUI scripts and styles, there is a custom theme for jQueryUI in the compressed file downloaded at the section JQueryElement.dll Download of Download JQueryElement, if you need more themes, you can get them at jqueryui.com/download:

<link type="text/css" rel="stylesheet"
 href="[style path]/jquery-ui-<version>.custom.css" />
<script type="text/javascript"
 src="[script path]/jquery-<version>.min.js"></script>
<script type="text/javascript"
 src="[script path]/jquery-ui-<version>.custom.min.js"></script>
  

Progress

Through the property Value to initialize the progress, Value should be between 0 and 100.

You can also use javascript on the client to set or get the progress, more information please refer to docs.jquery.com/UI/Progressbar:

<je:Progressbar ID="pb" runat="server" ScriptPackageID="package"
 CssClass="info-bar" IsVariable="true">
</je:Progressbar>

<script type="text/javascript">
 $(function () {
  var p = progressbar('option', 'value');
  p += 20;

  pb.progressbar('option', 'value', p);
 });
</script>
  

In the above example, set the IsVariable property of Progressbar to true, it'll generate a javascript variable named pb. You can use pb to get and set the progress of progressbar.

Appendix: The Percentage Of Information

In this section, we use Progressbar to show the percentage of user information:

<je:Progressbar ID="pb" runat="server" ScriptPackageID="package" Value="20">
</je:Progressbar>

...

<je:ScriptPackage ID="package" runat="server" />
  

Here is a progress bar, its corresponding javascript will be generated in the ScriptPackage control which the ID is package.

After the page loads, it'll call the method init that generated by AjaxManager:

<je:AjaxManager ID="ajax" runat="server">
 <je:AjaxSetting ClientFunction="init" Url="userinfo1.ashx" Success="
  function(data){
   $('#prec').text(-:data.prec + '%');
   pb.progressbar('option', 'value', -:data.prec);

   $('#realname').val(-:data.realname);
   $('#nickname').val(-:data.nickname);
   $('#email').val(-:data.email);
   $('#sex').val(-:data.sex);
   $('#birthday').val(-:data.birthday);
  }
  ">
  <je:Parameter Name="c" Type="Expression" Value="'get'" />
 </je:AjaxSetting>
</je:AjaxManager>

...

<script type="text/javascript">
 $(function () {
  init();
 });
</script>
  

The role of init method is to get user information from the userinfo1.ashx, and the information will be displayed on the page. For more AjaxManager information, please refer to Use AjaxManager To Generate javascript That Calls The Server-Side Method.

In the above code, -:data will be replaced by data or data.d based on different .NET version, more information, please refer to Return JSON In Different .NET Version.

Finally, we need a save button:

<je:Button ID="cmdSave" runat="server" ScriptPackageID="package"
 Label="You can always save">
 <ClickAsync Url="userinfo1.ashx" Success="
 function(data){
  $('#prec').text(-:data.prec + '%');
  pb.progressbar('option', 'value', -:data.prec);

  alert('ok');
 }
 ">
  <je:Parameter Name="c" Type="Expression" Value="'save'" />
  <je:Parameter Name="realname" Type="Selector" Value="'#realname'" />
  <je:Parameter Name="nickname" Type="Selector" Value="'#nickname'" />
  <je:Parameter Name="email" Type="Selector" Value="'#email'" />
  <je:Parameter Name="sex" Type="Selector" Value="'#sex'" />
  <je:Parameter Name="birthday" Type="Selector" Value="'#birthday'" />
 </ClickAsync>
</je:Button>
  

When you click on the button, user information on the pages will be passed to userinfo1.ashx, userinfo1.ashx will return the percentage of information.

In AjaxManager and the ClickAsync property of Button, we use the Parameter to increase the parameter, more information can refer to Through Parameter Object Add Ajax Request Parameter.

Revision History

Return JSON In Different .NET Version
Use AjaxManager To Generate javascript That Calls The Server-Side Method
Through Parameter Object Add Ajax Request Parameter

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

zoyobar

United States United States
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalmy vote of 4memberUday P.Singh30-Dec-11 5:46 
GeneralMy vote of 5memberAbinash Bishoyi27-Dec-11 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130617.1 | Last Updated 26 Dec 2011
Article Copyright 2011 by zoyobar
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid