Animation on Page

Discussion in 'ASP .Net' started by =?Utf-8?B?c2lhag==?=, May 4, 2005.

  1. Hello,
    I am trying to put a very simple animation on a page. I want two images to
    show alternately in a defined area. I tried to have an image control and a
    timer control on a page. I am setting the Imageurl property of the image
    control to two difeent images at fixed time interval. but the image remains
    fixed on my page. It never resets to other image. Perhaps I need to Refresh
    the page at every timeinterval.

    My code is as


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    SetTimer()
    End Sub


    Private Sub SetTimer()
    Try
    AddHandler Timer1.Elapsed, AddressOf OnTimer
    Timer1.Enabled = True
    Timer1.Interval = 1000

    Timer1.Start()
    Image1.ImageUrl = "C:\Sunset.jpg"
    Catch ex As Exception
    Response.Write(ex.Message)
    End Try
    End Sub


    Public Sub OnTimer(ByVal source As Object, ByVal e As ElapsedEventArgs)
    Try
    If Image1.ImageUrl = "C:\Sunset.jpg" Then
    Image1.ImageUrl = "C:\Winter.jpg"
    Else
    Image1.ImageUrl = "C:\Sunset.jpg"
    End If


    Catch ex As Exception
    Response.write(ex.Message)
    End Try
    End Sub



    Any suggestion shall be appreciated.

    Cheers,
    siaj
     
    =?Utf-8?B?c2lhag==?=, May 4, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?c2lhag==?=

    Joseph Byrns Guest

    You should do it in the JavaScript on the client so:

    function init()
    {
    timer = setInterval("TrackFrame()",500);
    }

    function TrackFrame()
    {
    //toggle image here
    }

    and call the init function from the body.

    "siaj" <> wrote in message
    news:...
    > Hello,
    > I am trying to put a very simple animation on a page. I want two images
    > to
    > show alternately in a defined area. I tried to have an image control and a
    > timer control on a page. I am setting the Imageurl property of the image
    > control to two difeent images at fixed time interval. but the image
    > remains
    > fixed on my page. It never resets to other image. Perhaps I need to
    > Refresh
    > the page at every timeinterval.
    >
    > My code is as
    >
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    > SetTimer()
    > End Sub
    >
    >
    > Private Sub SetTimer()
    > Try
    > AddHandler Timer1.Elapsed, AddressOf OnTimer
    > Timer1.Enabled = True
    > Timer1.Interval = 1000
    >
    > Timer1.Start()
    > Image1.ImageUrl = "C:\Sunset.jpg"
    > Catch ex As Exception
    > Response.Write(ex.Message)
    > End Try
    > End Sub
    >
    >
    > Public Sub OnTimer(ByVal source As Object, ByVal e As ElapsedEventArgs)
    > Try
    > If Image1.ImageUrl = "C:\Sunset.jpg" Then
    > Image1.ImageUrl = "C:\Winter.jpg"
    > Else
    > Image1.ImageUrl = "C:\Sunset.jpg"
    > End If
    >
    >
    > Catch ex As Exception
    > Response.write(ex.Message)
    > End Try
    > End Sub
    >
    >
    >
    > Any suggestion shall be appreciated.
    >
    > Cheers,
    > siaj
     
    Joseph Byrns, May 4, 2005
    #2
    1. Advertising

  3. Thanks for quick reply...
    I tried the way u suggested though I had two doubts..

    My Javascript code goes as
    <script language ="javascript" >
    var flag = true;
    function init()
    {
    alert("I m here!");
    timer = setInterval("TrackFrame",500);

    }
    function TrackFrame()
    {
    if flag == false
    {
    alert("toggling");
    flag = true;
    }
    else
    {
    alert("toggled");
    flag = false;
    }


    }
    </script>

    I call from the body as

    <body MS_POSITIONING="GridLayout" onload = "init()">

    My doubts are that I get an error Expected "("
    also If you can tell me how to toggle the image in javascript.

    Let me confess that I am a beginner in web development.

    Appreciate your help..
    Cheers,
    siaj

    "Joseph Byrns" wrote:

    > You should do it in the JavaScript on the client so:
    >
    > function init()
    > {
    > timer = setInterval("TrackFrame()",500);
    > }
    >
    > function TrackFrame()
    > {
    > //toggle image here
    > }
    >
    > and call the init function from the body.
    >
    > "siaj" <> wrote in message
    > news:...
    > > Hello,
    > > I am trying to put a very simple animation on a page. I want two images
    > > to
    > > show alternately in a defined area. I tried to have an image control and a
    > > timer control on a page. I am setting the Imageurl property of the image
    > > control to two difeent images at fixed time interval. but the image
    > > remains
    > > fixed on my page. It never resets to other image. Perhaps I need to
    > > Refresh
    > > the page at every timeinterval.
    > >
    > > My code is as
    > >
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > > 'Put user code to initialize the page here
    > > SetTimer()
    > > End Sub
    > >
    > >
    > > Private Sub SetTimer()
    > > Try
    > > AddHandler Timer1.Elapsed, AddressOf OnTimer
    > > Timer1.Enabled = True
    > > Timer1.Interval = 1000
    > >
    > > Timer1.Start()
    > > Image1.ImageUrl = "C:\Sunset.jpg"
    > > Catch ex As Exception
    > > Response.Write(ex.Message)
    > > End Try
    > > End Sub
    > >
    > >
    > > Public Sub OnTimer(ByVal source As Object, ByVal e As ElapsedEventArgs)
    > > Try
    > > If Image1.ImageUrl = "C:\Sunset.jpg" Then
    > > Image1.ImageUrl = "C:\Winter.jpg"
    > > Else
    > > Image1.ImageUrl = "C:\Sunset.jpg"
    > > End If
    > >
    > >
    > > Catch ex As Exception
    > > Response.write(ex.Message)
    > > End Try
    > > End Sub
    > >
    > >
    > >
    > > Any suggestion shall be appreciated.
    > >
    > > Cheers,
    > > siaj

    >
    >
    >
     
    =?Utf-8?B?c2lhag==?=, May 4, 2005
    #3
  4. =?Utf-8?B?c2lhag==?=

    Joseph Byrns Guest

    Here is a simple example (the error you got was because you missed the
    brackets in the if statement).

    <HEAD>
    <script language ="javascript" >
    var flag = true;
    var img = null;
    function init()
    {
    img = document.getElementById("TheImage");
    timer = setInterval("TrackFrame()",500);
    }

    function TrackFrame()
    {
    if (flag == false)
    {
    img.src="pic1.jpg";
    flag = true;
    }
    else
    {
    img.src="pic2.jpg";
    flag = false;
    }
    }

    </script>
    </HEAD>

    <BODY onload="init()">

    <img src="pic1.jpg" id="TheImage">

    </BODY>

    "siaj" <> wrote in message
    news:...
    > Thanks for quick reply...
    > I tried the way u suggested though I had two doubts..
    >
    > My Javascript code goes as
    > <script language ="javascript" >
    > var flag = true;
    > function init()
    > {
    > alert("I m here!");
    > timer = setInterval("TrackFrame",500);
    >
    > }
    > function TrackFrame()
    > {
    > if flag == false
    > {
    > alert("toggling");
    > flag = true;
    > }
    > else
    > {
    > alert("toggled");
    > flag = false;
    > }
    >
    >
    > }
    > </script>
    >
    > I call from the body as
    >
    > <body MS_POSITIONING="GridLayout" onload = "init()">
    >
    > My doubts are that I get an error Expected "("
    > also If you can tell me how to toggle the image in javascript.
    >
    > Let me confess that I am a beginner in web development.
    >
    > Appreciate your help..
    > Cheers,
    > siaj
    >
    > "Joseph Byrns" wrote:
    >
    >> You should do it in the JavaScript on the client so:
    >>
    >> function init()
    >> {
    >> timer = setInterval("TrackFrame()",500);
    >> }
    >>
    >> function TrackFrame()
    >> {
    >> //toggle image here
    >> }
    >>
    >> and call the init function from the body.
    >>
    >> "siaj" <> wrote in message
    >> news:...
    >> > Hello,
    >> > I am trying to put a very simple animation on a page. I want two
    >> > images
    >> > to
    >> > show alternately in a defined area. I tried to have an image control
    >> > and a
    >> > timer control on a page. I am setting the Imageurl property of the
    >> > image
    >> > control to two difeent images at fixed time interval. but the image
    >> > remains
    >> > fixed on my page. It never resets to other image. Perhaps I need to
    >> > Refresh
    >> > the page at every timeinterval.
    >> >
    >> > My code is as
    >> >
    >> >
    >> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    >> > System.EventArgs) Handles MyBase.Load
    >> > 'Put user code to initialize the page here
    >> > SetTimer()
    >> > End Sub
    >> >
    >> >
    >> > Private Sub SetTimer()
    >> > Try
    >> > AddHandler Timer1.Elapsed, AddressOf OnTimer
    >> > Timer1.Enabled = True
    >> > Timer1.Interval = 1000
    >> >
    >> > Timer1.Start()
    >> > Image1.ImageUrl = "C:\Sunset.jpg"
    >> > Catch ex As Exception
    >> > Response.Write(ex.Message)
    >> > End Try
    >> > End Sub
    >> >
    >> >
    >> > Public Sub OnTimer(ByVal source As Object, ByVal e As ElapsedEventArgs)
    >> > Try
    >> > If Image1.ImageUrl = "C:\Sunset.jpg" Then
    >> > Image1.ImageUrl = "C:\Winter.jpg"
    >> > Else
    >> > Image1.ImageUrl = "C:\Sunset.jpg"
    >> > End If
    >> >
    >> >
    >> > Catch ex As Exception
    >> > Response.write(ex.Message)
    >> > End Try
    >> > End Sub
    >> >
    >> >
    >> >
    >> > Any suggestion shall be appreciated.
    >> >
    >> > Cheers,
    >> > siaj

    >>
    >>
    >>
     
    Joseph Byrns, May 5, 2005
    #4
    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. Brian Henry

    upload animation on web page

    Brian Henry, Mar 20, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    5,549
    Brian Henry
    Mar 22, 2005
  2. JohnH.
    Replies:
    9
    Views:
    614
    R-D-C
    Apr 3, 2005
  3. Replies:
    3
    Views:
    371
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 12, 2007
  4. Mantorok

    Display animation during page-load

    Mantorok, Jun 19, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    741
    Mantorok
    Jun 20, 2007
  5. gealover
    Replies:
    2
    Views:
    134
    Jonas Raoni Soares Silva
    Dec 15, 2008
Loading...

Share This Page