• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

ASP.net Run VB.net code while Timer is running


I have an ASP.net website, which shows images of venues in a GridView. I have VB.net code behind for buttons that refreshes the information in a different order. I have now used the code below to show alternating images.
The problem is that now that the Timer is running, my VB.net code to refresh the Gridview doesn't.
  Protected Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Call Display_Next_Image()
    End Sub

    Sub Display_Next_Image()
            Dim intLast As Integer = CInt(Me.lblImageNumber.Text)
            Dim oNextNumber As String

            If intLast = 10 Then
                Me.Image1.ImageUrl = "~/Images_Slide2/1.jpg"

                Me.lblImageNumber.Text = "1"
                oNextNumber = intLast + 1
                Me.Image1.ImageUrl = "~/Images_Slide2/" & oNextNumber.ToString & ".jpg"
                Me.lblImageNumber.Text = oNextNumber.ToString
            End If

        Catch ex As Exception
        End Try
    End Sub
Murray Brown
Murray Brown
  • 2
  • 2
2 Solutions
This sort of image juggling is usually done in JavaScript

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks for the info. I would really like to try and sort this out with a technique that does not employ Java Script
The problem with current approach is that a request may be already in progress when you try to refresh the grid.
Easy slider
<html xmlns="http://www.w3.org/1999/xhtml">
    <title>Easy slider</title>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('.slider img:gt(0)').hide();
            setInterval(function () { $('.slider :first-child').fadeOut(2000).next('img').fadeIn(2000).end().appendTo('.slider'); }, 5000); /*5 sec*/ 
    <style type="text/css">
	.slider { clear:both; position:relative; height:240px; width:950px; }
	.slider img { position:absolute; left:0; top:0;cursor:pointer; }
    <div class="slider" style="margin:0 auto;">
        <img src="Images_Slide2/1.jpg" />
        <img src="Images_Slide2/2.jpg" />
        <img src="Images_Slide2/3.jpg" />
        <img src="Images_Slide2/4.jpg" />
        <img src="Images_Slide2/5.jpg" />
        <img src="Images_Slide2/6.jpg" />
        <img src="Images_Slide2/7.jpg" />
        <img src="Images_Slide2/8.jpg" />
        <img src="Images_Slide2/9.jpg" />

Open in new window

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks for the help
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now