Click here to Skip to main content
15,896,278 members
Articles / Web Development / HTML5

AJAX Progress Bar for ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.80/5 (33 votes)
11 Jun 2014CPOL4 min read 171.3K   8K   51  
Async Progress Indicator with Messages and OnComplete Event
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace hmlib.Web.UI.Controls
{
	public partial class Progress
	{
		public string ID { get; private set; }
		private double? _value;
		public double? Value
		{
			get { return this._value; }
			private set
			{
				this._value = value;
				this.ChangedOn = DateTime.Now;
			}
		}
		public DateTime ChangedOn { get; private set; }
		public DateTime CreatedOn { get; private set; }
		private List<string> NewLines = new List<string>();
		private Progress(string id)
		{
			this.ID = id;
			this.Value = null;
			this.ChangedOn = DateTime.Now;
			this.CreatedOn = DateTime.Now;
			Progress._list.Add(this);
			Progress.CleanUp();
		}
		public bool SetProgress(double value)
		{
			this.Value = value;
			return true;
		}
		public bool AddMessageLine(object msg)
		{
			if (msg == null) return false;
			this.NewLines.Add(msg.ToString());
			return true;
		}
		public bool AddMessageLines(string[] lines)
		{
			foreach (var line in lines)
			{
				this.AddMessageLine(line);
			}
			return true;
		}
		public object State { get; set; }
		public void ClearProgress()
		{
			this.Value = null;
			this.NewLines.Clear();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior) FDK
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions