Friday, December 5, 2008

Creating ProgressBar in asp.net

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ProgressBar.ascx.vb" Inherits="ProgressBar" %><%@ Control Language="VB" AutoEventWireup="false" CodeFile="ProgressBar.ascx.vb" Inherits="ProgressBar" %>------------------------------------html--------------
  1. <%@ Control Language="VB" AutoEventWireup="false" CodeFile="ProgressBar.ascx.vb" Inherits="ProgressBar" %><%@ Control Language="VB" AutoEventWireup="false" CodeFile="ProgressBar.ascx.vb" Inherits="ProgressBar" %>

    ---------------------------------------------------
    Partial Class ProgressBar Inherits System.Web.UI.UserControl
    Private _colFillColor As Drawing.Color Private _colBackcolor As Drawing.Color Private _colBorderColor As Drawing.Color = Drawing.Color.Black
    Private _intBorder As Integer = 1 Private _intCellspacing As Integer = 1 Private _intCellpadding As Integer = 1 Private _intHeight As Integer = 10 Private _intWidth As Integer = 100
    Private _intBlockNumber As Integer = 5 Private _intValue As Integer = 0 Private _tblBlock As TableRow
    Private _caption As String
    Public Property BGColor() As Drawing.Color Get Return _colBackcolor End Get Set(ByVal value As Drawing.Color) _colBackcolor = value End Set End Property Public Property FillColor() As Drawing.Color Get Return _colFillColor End Get Set(ByVal value As Drawing.Color) _colFillColor = value End Set End Property Public Property BorderColor() As Drawing.Color Get Return _colBorderColor End Get Set(ByVal value As Drawing.Color) _colBorderColor = value End Set End Property Public Property BorderSize() As Integer Get Return _intBorder End Get Set(ByVal value As Integer) _intBorder = value End Set End Property Public Property Cellpadding() As Integer Get Return _intCellpadding End Get Set(ByVal value As Integer) _intCellpadding = value End Set End Property Public Property CellSpacing() As Integer Get Return _intCellspacing End Get Set(ByVal value As Integer) _intCellspacing = value End Set End Property Public Property Blocks() As Integer Get Return _intBlockNumber End Get Set(ByVal value As Integer) _intBlockNumber = value End Set End Property
    Public Property Value() As Integer Get Return _intValue End Get Set(ByVal value As Integer) _intValue = value End Set End Property
    Public Property Caption() As String Get Return _caption End Get Set(ByVal value As String) _caption = value End Set End Property
    Public Property Height() As Integer Get Return _intHeight End Get Set(ByVal value As Integer) _intHeight = value End Set End Property Public Property Width() As Integer Get Return _intWidth End Get Set(ByVal value As Integer) _intWidth = value End Set End Property
    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender Dim intBlocks As Integer
    ' add a new row to the table _tblBlock = New TableRow() ' create cells and add to the row For intBlocks = 1 To Me.Blocks Dim tblCell As New TableCell tblCell.Text = " " If intBlocks <= Math.Floor((Me.Value * Me.Blocks / 100)) Then tblCell.BackColor = Me.FillColor End If _tblBlock.Cells.Add(tblCell) Next tblProgressBar.Rows.Add(_tblBlock) 'set the progress bar properties tblProgressBar.CellPadding = Me.Cellpadding tblProgressBar.CellSpacing = Me.CellSpacing tblProgressBar.Width = Me.Width tblProgressBar.Height = Me.Height tblProgressBar.BackColor = Me.BGColor tblProgressBar.BorderColor = Me.BorderColor tblProgressBar.Caption = Me.Caption tblProgressBar.ToolTip = Me.Value & "% " End Sub End Class

No comments:

Post a Comment