ComponentOne ProgressBar for ASP.NET AJAX: ProgressBar for ASP.NET AJAX Quick Start > Step 3 of 4: Coding the Project

Step 3 of 4: Coding the Project

In this step of the quick start, you will create a Timer1_Tick event handler and a Button1_Click event handler.  In the Timer1_Tick event handler, you will add code that determines the behavior of the C1ProgressBar control; in the Button_Click event handler, you will add code that initializes the Timer control and resets the Value property of the C1ProgressBar.

1.   Double-click the Timer control. This will add the Timer1_Tick even to Code view.

2.   Place the following code within the Timer1_Tick event:

      Visual Basic

If C1ProgressBar1.Value = C1ProgressBar1.MaximumValue Then

'When the progress bar reaches MaximumValue, stop the timer and change label value / alignment

Timer1.Enabled = False

C1ProgressBar1.LabelFormatString = "Task Completed!"

C1ProgressBar1.LabelAlign = C1.Web.UI.Controls.C1ProgressBar.ProgressBarLabelAlign.Center

End If

If True Then

'If C1ProgressBar’s Value property is less than the MaximumValue property, increase the Value property by 5

C1ProgressBar1.Value = C1ProgressBar1.Value + 5

End If

 

      C#

if (C1ProgressBar1.Value == C1ProgressBar1.MaximumValue)

{

//When the progress bar reaches MaximumValue, stop the timer and change label value/alignment

Timer1.Enabled = false;

C1ProgressBar1.LabelFormatString = "Task Completed!";

C1ProgressBar1.LabelAlign = ProgressBarLabelAlign.Center;

}

{

// If C1ProgressBar’s Value property is less than the MaximumValue property, increase the Value property by 5

C1ProgressBar1.Value = C1ProgressBar1.Value + 5;

}

3.   Click the proper Default.aspx tab to return to Design view. 

4.   Double-click the Button control to add the Button1_Click event handler to code view.

5.   Place the following code within the  Button1_Click event:

      Visual Basic

‘Enable Timer control and reset C1ProgressBar.Value upon button click

Timer1.Enabled = true

C1ProgressBar1.Value = 0

 

      C#

//Enable Timer control and reset C1ProgressBar.Value upon button click

Timer1.Enabled = true;

C1ProgressBar1.Value = 0;

Step 3 of 4 Completed Step3of4.png

In this step, you coded behaviors for the Timer control and the C1ProgressBar control. In the next step, you will run the project and observe the behaviors.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.