Thanks for the help KC. I just learned that meta-tag refreshing is
re-loading the page, not re-posting the page.
dbui
here is my final code 4 whoever may need
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If (IsNothing(Session("P"))) Then
Dim pics() As String =
Directory.GetFileSystemEntries(Server.MapPath("\im ages"), "*.jpg")
If pics.Length > 0 Then
Image1.ImageUrl = pics(0)
Session("P") = pics
Session("i") = 0
End If
Else
Dim pics() As String = Session("P")
Dim i As Integer = Session("i") + 1
If (i >= pics.Length) Then i = 0
Image1.ImageUrl = pics(i)
Session("i") = i
End If
End Sub
"Ken Cox [Microsoft MVP]" <> wrote in message
news:...
> One way is to use some HTML in the page to cause the refresh and a Session
> variable to track the index. I'm using a label for convenience here but
> you'd want to pass Session("imageno") to your routine:
>
>
> ' This is the web user control
> Private Sub Page_Load _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> If IsNothing(Session("imageno")) Then
> Label1.Text = "Get the first image."
> Else
> Label1.Text = "Go get image # " & _
> Session("imageno").ToString
> End If
> End Sub
>
> ' This is in the .aspx.vb code behind
> Private Sub Page_Load _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> Session("imageno") = Session("imageno") + 1
> End Sub
>
> Private Sub Button1_Click _
> (ByVal sender As System.Object, ByVal e As System.EventArgs) _
> Handles Button1.Click
> End Sub
>
> This is the .aspx page
>
> <%@ Register TagPrefix="uc1" TagName="imgfle" Src="imgfle.ascx" %>
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="countimage.aspx.vb" Inherits="p4320work.countimage"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html>
> <head><meta http-equiv="refresh" content="600">
> <title>countimage</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </head>
> <body MS_POSITIONING="FlowLayout">
> <form id="Form1" method="post" runat="server">
> <p>
> <uc1:imgfle id="Imgfle1" runat="server"></uc1:imgfle></p>
> <p>
> <asp:button id="Button1" runat="server"
> Text="Next"></asp:button></p>
> </form>
> </body>
> </html>
>
>
> "dbui" <> wrote in message
> news:...
> > Hi,
> >
> > I got a simple ascx. It has one image component. When first loaded, it
> > scans
> > thru \images folder, loads the first image, and save the index & the
> > string
> > array of picture names in session.
> >
> > When user click on the Next button, it will increase the index by one
and
> > reload the image according to this new index value.
> >
> > I want this web-control to be able to refresh itself every 5 seconds.
And
> > it
> > could increase the index and load the image of this index in the array
> > names.
> >
> > What is the best way in asp.net (not other scripts) to archieve this?
> >
> > Thanks.
> >
> >
>
|