J
Jim in Arizona
I created a public application based variable not within any procedure,
like so:
Partial Class lobbytimes_lobbytimes
Inherits System.Web.UI.Page
Public BackgroundImage As String
Protected Sub Page_Load(ByVal ..)
I then created a background image randomizer subroutine and placed that
into 'If not Page.IsPostback' decision on the page load routine, like so:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
LoadBackground()
End If
End Sub
And here's the LoadBackground routine:
Sub LoadBackground()
Randomize()
Dim imagegen(2) As String
Dim x As Short
x = CShort(Rnd() * 2)
imagegen(0) = "../lobbytimes/backgrounds/a1.gif"
imagegen(1) = "../lobbytimes/backgrounds/a2.gif"
imagegen(2) = "../lobbytimes/backgrounds/1.jpg"
BackgroundImage = imagegen(x)
End Sub
And on the aspx page, I put this:
<body background="<%Response.write(BackgroundImage)%>">
So, the problem is that when the page first loads, the random background
image loads fine. But, on any postback event (which there are several on
this application), the background image disappears and all that's left
is a white background (nothing).
Sure, I could place the LoadBackground routine under the Page_Load Sub,
but it would be annoying to see the background change 100 times a day.
I wanted the random image to load once and stay there while they used
the application.
Any ideas?
TIA,
Jim
like so:
Partial Class lobbytimes_lobbytimes
Inherits System.Web.UI.Page
Public BackgroundImage As String
Protected Sub Page_Load(ByVal ..)
I then created a background image randomizer subroutine and placed that
into 'If not Page.IsPostback' decision on the page load routine, like so:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
LoadBackground()
End If
End Sub
And here's the LoadBackground routine:
Sub LoadBackground()
Randomize()
Dim imagegen(2) As String
Dim x As Short
x = CShort(Rnd() * 2)
imagegen(0) = "../lobbytimes/backgrounds/a1.gif"
imagegen(1) = "../lobbytimes/backgrounds/a2.gif"
imagegen(2) = "../lobbytimes/backgrounds/1.jpg"
BackgroundImage = imagegen(x)
End Sub
And on the aspx page, I put this:
<body background="<%Response.write(BackgroundImage)%>">
So, the problem is that when the page first loads, the random background
image loads fine. But, on any postback event (which there are several on
this application), the background image disappears and all that's left
is a white background (nothing).
Sure, I could place the LoadBackground routine under the Page_Load Sub,
but it would be annoying to see the background change 100 times a day.
I wanted the random image to load once and stay there while they used
the application.
Any ideas?
TIA,
Jim