An alternative solution is to use an simple user control. The disadvantage is the look & feel of the progress bar. It's not as good looking as the progress bar from EO, but you can get the full source code. Here is the code in c#:
ProgressBar.aspx:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProgressBar.ascx.cs" Inherits="ProgressBar" %>
CellPadding="1"
CellSpacing="1"
Height="10px"
Width="200px">
ProgressBar.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ProgressBar : System.Web.UI.UserControl
{
private System.Drawing.Color _colFillColor = System.Drawing.Color.Green;
private System.Drawing.Color _colBackcolor = System.Drawing.Color.White;
private System.Drawing.Color _colBorderColor = System.Drawing.Color.Black;
private int _intBorder = 1;
private int _intCellspacing = 1;
private int _intCellpadding = 1;
private int _intHeight = 15;
private int _intWidth = 130;
private int _intBlockNumber = 20;
private int _intValue;
TableRow _tblBlock;
public System.Drawing.Color BGColor
{
get
{
return _colBackcolor;
}
set
{
_colBackcolor = value;
}
}
public System.Drawing.Color FillColor
{
get
{
return _colFillColor;
}
set
{
_colFillColor = value;
}
}
public System.Drawing.Color BorderColor
{
get
{
return _colBorderColor;
}
set
{
_colBorderColor = value;
}
}
public int BorderSize
{
get
{
return _intBorder;
}
set
{
_intBorder = value;
}
}
public int Cellpadding
{
get
{
return _intCellpadding;
}
set
{
_intCellpadding = value;
}
}
public int CellSpacing
{
get
{
return _intCellspacing;
}
set
{
_intCellspacing = value;
}
}
public int Blocks
{
get
{
return _intBlockNumber;
}
set
{
_intBlockNumber = value;
}
}
public int Value
{
get
{
return _intValue;
}
set
{
_intValue = value;
}
}
public int Height
{
get
{
return _intHeight;
}
set
{
_intHeight = value;
}
}
public int Width
{
get
{
return _intWidth;
}
set
{
_intWidth = value;
}
}
protected void Page_PreRender(object sender, System.EventArgs e)
{
int intBlocks;
// add a new row to the table
_tblBlock = new TableRow();
// create cells and add to the row
for (intBlocks = 1; (intBlocks <= this.Blocks); intBlocks++)
{
TableCell tblCell = new TableCell();
tblCell.Text = " ";
decimal temp = (Convert.ToDecimal(this.Blocks) / 100) * Convert.ToDecimal(this.Value);
if ((intBlocks <= temp))
{
tblCell.BackColor = this.FillColor;
}
_tblBlock.Cells.Add(tblCell);
}
tblProgressBar.Rows.Add(_tblBlock);
// set the progress bar properties
tblProgressBar.CellPadding = this.Cellpadding;
tblProgressBar.CellSpacing = this.CellSpacing;
tblProgressBar.Width = this.Width;
tblProgressBar.Height = this.Height;
tblProgressBar.BackColor = this.BGColor;
tblProgressBar.BorderColor = this.BorderColor;
LabelProgress.Text = this.Value + "% complete";
}
}
No comments:
Post a Comment