Displaying Panel After Timer Loop

Discussion in 'ASP .Net' started by J Snaith, Apr 1, 2010.

  1. J Snaith

    J Snaith Guest

    Good day. I have asp.net page in vb.net that gets set of photos records
    from a database table (paths to photos). Loads that data into session
    datatable, divide into parts and display each part at timer interval. For
    eg. every 7 seconds display first 5 (of 20) photos in asp.net datagrid, then
    next set of 5, then next set of 5 photos, etcetera. When all 20 photos have
    been displayed (paged) I want to show new panel for 7 seconds (pnlWarning).
    Hide pnlViewPhotos and show pnlWarning. Then, start loop again and start
    displaying paged photos again (in pnlViewPhotos). Then after 20 display
    warning again, etcetera. I have the code working well to page photos but
    cannot determine where to show pnlWarning panel and hide other panel for the
    7 seconds after all photos displayed, then start displaying photos again
    after 7 seconds of making pnlWarning visible=true. Could you please take
    look at following code snippet and please advise where I may accomplish this
    tasks? Any direction you have would be appreciate and of great help. Thank
    you and have fantastic day.


    'click button to start
    Sub btnDisplayPagingPhotos_Click(ByVal sender As Object, ByVal e As
    System.EventArgs)
    Dim varPhotosID As String = 24
    session("thePageSize") = 7
    Timer1.Interval = 7 'seconds
    GetPhotos(varPhotosID)
    End Sub

    Private Sub GetPhotos(ByVal photosid As String)
    Dim ssql As String
    Dim cnn As New SqlConnection(ConfigurationSettings.AppSettings.Get("cnn"))
    cnn.Open()
    ssql = "exec procGetPhotos '" & photosid & "'"

    pnlViewPhotos.visible = True

    session("da") = New SqlDataAdapter(ssql, cnn)
    session("ds") = New DataSet
    session("da").Fill(session("ds"), "photos")
    session("dtPhotosSource") = session("ds").Tables("photos")

    getPhotosData()

    cnn.Close()
    End Sub

    Private Sub goToFirstSetOfPhotos()
    If session("theCurrentPage") = 1 Then
    Return
    End If
    session("theCurrentPage") = 1
    session("theRecordNumber") = 0
    LoadPhotos()
    End Sub

    Private Sub LoadPhotos()
    Timer1.Interval = ddlPagingInterval.SelectedItem.Value
    session("dtTemp") = session("dtPhotosSource").Clone
    If session("theCurrentPage") = session("thePageCount") Then
    session("endRec") = session("theMaxRecord")
    Else
    session("endRec") = session("thePageSize") * session("theCurrentPage")
    End If
    session("startRec") = session("theRecordNumber")

    'if photos actually exist
    Dim intCount As Integer
    intCount = session("dtPhotosSource").Rows.Count
    If intCount > 0 Then
    Dim i As Integer
    For i = session("startRec") To session("endRec") - 1
    session("dtTemp").ImportRow(session("dtPhotosSource").Rows(i))
    session("theRecordNumber") = session("theRecordNumber") + 1
    Next
    End If

    dgPhotos.DataSource = session("dtTemp")
    dgPhotos.Databind()
    End Sub

    Private Sub getPhotosData()
    session("theMaxRecord") = session("dtPhotosSource").Rows.Count
    session("thePageCount") = session("theMaxRecord") \ session("thePageSize")
    If (session("theMaxRecord") Mod session("thePageSize")) > 0 Then
    session("thePageCount") = session("thePageCount") + 1
    End If
    session("theCurrentPage") = 1
    session("theRecordNumber") = 0
    LoadPhotos()
    End Sub

    Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Timer1.Elapsed
    session("theCurrentPage") = session("theCurrentPage") + 1
    If session("theCurrentPage") > session("thePageCount") Then
    session("theCurrentPage") = session("thePageCount")
    If session("theRecordNumber") = session("theMaxRecord") Then
    session("theCurrentPage") = 1
    getPhotosData()
    goToFirstSetOfPhotos()
    Dim varPhotosID As String = 24
    GetPhotos(photosid)
    Return
    End If
    End If
    LoadPhotos()
    End Sub
    J Snaith, Apr 1, 2010
    #1
    1. Advertising

  2. On Apr 1, 2:53 pm, "J Snaith" <> wrote:
    > Good day.  I have asp.net page in vb.net that gets set of photos records
    > from a database table (paths to photos).  Loads that data into session
    > datatable, divide into parts and display each part at timer interval.  For
    > eg. every 7 seconds display first 5 (of 20) photos in asp.net datagrid, then
    > next set of 5, then next set of 5 photos, etcetera.  When all 20 photos have
    > been displayed (paged) I want to show new panel for 7 seconds (pnlWarning).
    > Hide pnlViewPhotos and show pnlWarning.  Then, start loop again and start
    > displaying paged photos again (in pnlViewPhotos).  Then after 20 display
    > warning again, etcetera.  I have the code working well to page photos but
    > cannot determine where to show pnlWarning panel and hide other panel for the
    > 7 seconds after all photos displayed, then start displaying photos again
    > after 7 seconds of making pnlWarning visible=true.  Could you please take
    > look at following code snippet and please advise where I may accomplish this
    > tasks?  Any direction you have would be appreciate and of great help.  Thank
    > you and have fantastic day.
    >
    > 'click button to start
    > Sub btnDisplayPagingPhotos_Click(ByVal sender As Object, ByVal e As
    > System.EventArgs)
    >         Dim varPhotosID As String = 24
    >         session("thePageSize") = 7
    >         Timer1.Interval = 7 'seconds
    >         GetPhotos(varPhotosID)
    > End Sub
    >
    > Private Sub GetPhotos(ByVal photosid As String)
    >         Dim ssql As String
    >         Dim cnn As New SqlConnection(ConfigurationSettings.AppSettings.Get("cnn"))
    >         cnn.Open()
    >         ssql = "exec procGetPhotos '" & photosid & "'"
    >
    >         pnlViewPhotos.visible = True
    >
    >         session("da") = New SqlDataAdapter(ssql, cnn)
    >         session("ds") = New DataSet
    >         session("da").Fill(session("ds"), "photos")
    >         session("dtPhotosSource") = session("ds").Tables("photos")
    >
    >         getPhotosData()
    >
    >         cnn.Close()
    > End Sub
    >
    > Private Sub goToFirstSetOfPhotos()
    >         If session("theCurrentPage") = 1 Then
    >                 Return
    >         End If
    >         session("theCurrentPage") = 1
    >         session("theRecordNumber") = 0
    >         LoadPhotos()
    > End Sub
    >
    > Private Sub LoadPhotos()
    >         Timer1.Interval = ddlPagingInterval.SelectedItem.Value
    >         session("dtTemp") = session("dtPhotosSource").Clone
    >         If session("theCurrentPage") = session("thePageCount") Then
    >                 session("endRec") = session("theMaxRecord")
    >         Else
    >                 session("endRec") = session("thePageSize") * session("theCurrentPage")
    >         End If
    >         session("startRec") = session("theRecordNumber")
    >
    >         'if photos actually exist
    >         Dim intCount As Integer
    >         intCount = session("dtPhotosSource").Rows.Count
    >         If intCount > 0 Then
    >                 Dim i As Integer
    >                 For i = session("startRec") To session("endRec") - 1
    >                         session("dtTemp").ImportRow(session("dtPhotosSource").Rows(i))
    >                         session("theRecordNumber") = session("theRecordNumber") + 1
    >                 Next
    >         End If
    >
    >         dgPhotos.DataSource = session("dtTemp")
    >         dgPhotos.Databind()
    > End Sub
    >
    > Private Sub getPhotosData()
    >         session("theMaxRecord") = session("dtPhotosSource").Rows.Count
    >         session("thePageCount") = session("theMaxRecord") \ session("thePageSize")
    >         If (session("theMaxRecord") Mod session("thePageSize")) > 0 Then
    >                 session("thePageCount") = session("thePageCount") + 1
    >         End If
    >         session("theCurrentPage") = 1
    >         session("theRecordNumber") = 0
    >         LoadPhotos()
    > End Sub
    >
    > Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles Timer1.Elapsed
    >         session("theCurrentPage") = session("theCurrentPage") + 1
    >         If session("theCurrentPage") > session("thePageCount") Then
    >                 session("theCurrentPage") = session("thePageCount")
    >                 If session("theRecordNumber") = session("theMaxRecord") Then
    >                         session("theCurrentPage") = 1
    >                         getPhotosData()
    >                         goToFirstSetOfPhotos()
    >                         Dim varPhotosID As String = 24
    >                         GetPhotos(photosid)
    >                         Return
    >                 End If
    >         End If
    >         LoadPhotos()
    > End Sub


    Please look here
    http://groups.google.com/group/micr....aspnet/browse_thread/thread/adf79796a1935ca6
    Alexey Smirnov, Apr 12, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelsang Wangchuk

    System.Timers.Timer vs. System.Threading.Timer

    Kelsang Wangchuk, Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    707
    Kelsang Wangchuk
    Jul 31, 2003
  2. Replies:
    1
    Views:
    1,581
    Steve C. Orr [MVP, MCSD]
    Feb 22, 2005
  3. Simon

    page timer, or redirect timer

    Simon, Nov 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    11,189
    Bruce Barker
    Nov 4, 2005
  4. Isaac Won
    Replies:
    9
    Views:
    354
    Ulrich Eckhardt
    Mar 4, 2013
  5. Replies:
    8
    Views:
    482
    Jorgen Grahn
    Jul 15, 2013
Loading...

Share This Page