Well I have asked my question(s) in the ASP.Net forum area and in the VB.Net forum area, so I'll try here now....
I have a webpage written with VS2008 in VB.Net that was working fine, but I wanted to add a ProgressBar to it.
Many of the web references that I found indicated that I ought to try implementing AJAX in the page.
So I followed examples and put a single UPDATEPANEL into the form using a TimerControl (placed OUTSIDE of the UpdatePanel) as a Trigger.
It all looked easy to do and the methodology looked like it would do the job
The btnSubmit_Click (not really a SUBMIT Button) is supposed to 'launch' everything.
BUT it is not working. It appears as though the Timer is never 'firing' everything else.
I see the UpdateTables (the threaded process) executing fine, but I never see anything else occurring which in regards to the ProgressBar.
Any advice/suggestions you might have would be greatly appreciated.
Thanks,
JRB-Bldr
I have a webpage written with VS2008 in VB.Net that was working fine, but I wanted to add a ProgressBar to it.
Many of the web references that I found indicated that I ought to try implementing AJAX in the page.
So I followed examples and put a single UPDATEPANEL into the form using a TimerControl (placed OUTSIDE of the UpdatePanel) as a Trigger.
It all looked easy to do and the methodology looked like it would do the job
The btnSubmit_Click (not really a SUBMIT Button) is supposed to 'launch' everything.
BUT it is not working. It appears as though the Timer is never 'firing' everything else.
Code:
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="UpdtTimer" runat="server" OnTick="UpdateTimer_Tick" Interval=2000></asp:Timer>
<asp:UpdatePanel ID="ProgressBarUpdtPanel" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdtTimer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<div id="ProgBarBckGrnd" style="background-color:#FFFFFF; height:40px; width:300px">
<div id="GreenBar" runat="server" style="height:40px; width:0px; background-color:#99FF33">
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Code:
Protected Sub UpdateTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles UpdtTimer.Tick
Dim nNewPcntInt = Session("ProgressPcnt")
If nNewPcntInt = 100 Then
UpdtTimer.Enabled = False
End If
Dim divProgBarBckGrnd As HtmlGenericControl = Me.FindControl("ProgBarBckGrnd")
Dim divGrnBar As HtmlGenericControl = Me.FindControl("GreenBar")
Dim TotalWidth As Int16 = 300 'px
Dim NewGrnWidth As Int16 = TotalWidth * (nNewPcntInt / 100)
divGrnBar.Style.Item("width") = NewGrnWidth.ToString + "px"
End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click
Session("ProgressPcnt") = 0 ' <-- This Value gets updated within the UpdateTables threaded process
If RadioButtonList2.SelectedValue <> "" Then
If aSelectedDays.Count > 0 Then
Dim objThread As New Thread(New System.Threading.ThreadStart(AddressOf UpdateTables))
objThread.IsBackground = True
objThread.Start()
Session("Thread") = objThread
UpdtTimer.Interval = 2000 ' Timer <-- 1 Second Intervals
UpdtTimer.Enabled = True ' Enable Timer ' <-- LAUNCH Timer Events To Update ProgressBar
End If
Else
UpdtTimer.Enabled = False ' Disable Timer
jsMessageBox("INCLUDE / EXCLUDE Not Selected!", Me.Page)
End If
End Sub
Private Sub UpdateTables()
aLotName = Session.Item("LotNames")
For Cntr = 0 To (aLotName.Count - 1) ' Cycle Thru ALL Lots Looking for Selected (Checked)
' --- Do a Bunch of Stuff ---
' --- Determine New Percent Complete ---
Session("ProgressPcnt") = nNewPcntInt ' <-- [u]Hopefully[/u] The Timer TICK will update the ProgressBar in the UpdatePanel
System.Threading.Thread.Sleep(1500) ' Pause for 1 1/2 second
End If
Next
' --- DONE ---
System.Threading.Thread.Sleep(2000) ' Pause for 2 seconds
Session("ProgressPcnt") = 0
UpdtTimer.Enabled = False ' Disable Timer
' --- Close Threaded Process ---
Dim objThread As Thread = CType(Session("Thread"), Thread)
objThread.Abort()
UpdtTimer.Enabled = False
End Sub
I see the UpdateTables (the threaded process) executing fine, but I never see anything else occurring which in regards to the ProgressBar.
Any advice/suggestions you might have would be greatly appreciated.
Thanks,
JRB-Bldr