R
Rich P
I created a simple asp.net app with a code sample I found at
http://www.vb-tips.com/dbpages.aspx?IA=AN
This works from visual studio (2005). My problem is when I deploy it to
my server. I clicked on Publish and published it to a directory on the
server where my virtual directory exists. But the app won't run. My
problem may be with a string variable called scriptString.
Here is the code sample (2 web pages)
Partial Public Class _Default
Inherits System.Web.UI.Page
'''Form 1 Needs an imagebox on the page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Image1.Height = New Unit(32)
Image1.Width = New Unit(200)
Image1.Visible = True
'Beneath is the Timer
'--this commented out scriptString works on my local workstation
'Dim scriptString As String = "<script language=JavaScript>" &
"setclock(); function setclock(){document.images.Image1.src = " &
"'http://localhost:4863/WebForm2.aspx';setTimeout('setclock()',1000)}</s
cript>"
'--I changed " scriptString " to this one for the virtual dir on my
server where I deployed it to
Dim scriptString As String = "<script language=JavaScript>" &
"setclock(); function setclock(){document.images.Image1.src = " &
"'http://notify1/aspclock/WebForm2.aspx';setTimeout('setclock()',1000)}<
/script>"
Page.RegisterStartupScript("setclock", scriptString)
End Sub
End Class
and here is the 2nd page (WebForm2.aspx)
Imports System.Drawing
Partial Public Class WebForm2
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Response.Cache.SetExpires(DateTime.Now.AddTicks(500))
Dim myForeBrush As Brush = Brushes.Black
Dim myFont As New Font("Times New Roman", 8, FontStyle.Regular)
Dim textHeight As Single
Dim bm As New Bitmap(120, 20)
Dim g As Graphics = Graphics.FromImage(bm)
g.Clear(Color.White)
Dim textSize As SizeF = g.MeasureString(Now.ToString, myFont)
g.DrawString(Now.ToString, myFont, myForeBrush, _
New RectangleF(0, 0, 120, 20))
Dim ms As New IO.MemoryStream
Dim arrImage() As Byte
bm.Save(ms, Imaging.ImageFormat.Bmp)
arrImage = ms.GetBuffer
Response.BinaryWrite(arrImage)
g.dispose()
End Sub
End Class
I added custom error tags in the web.config file, but I don't get any
intuitive messages - just that the app won't run. Do I need to modify
scriptString? My deploy string was
\\myservername\notify\aspclock\
the virtual dir is called notify1, so I changed scriptString to
http//notify1/aspclock/webform2.aspx.
thanks,
Rich
http://www.vb-tips.com/dbpages.aspx?IA=AN
This works from visual studio (2005). My problem is when I deploy it to
my server. I clicked on Publish and published it to a directory on the
server where my virtual directory exists. But the app won't run. My
problem may be with a string variable called scriptString.
Here is the code sample (2 web pages)
Partial Public Class _Default
Inherits System.Web.UI.Page
'''Form 1 Needs an imagebox on the page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Image1.Height = New Unit(32)
Image1.Width = New Unit(200)
Image1.Visible = True
'Beneath is the Timer
'--this commented out scriptString works on my local workstation
'Dim scriptString As String = "<script language=JavaScript>" &
"setclock(); function setclock(){document.images.Image1.src = " &
"'http://localhost:4863/WebForm2.aspx';setTimeout('setclock()',1000)}</s
cript>"
'--I changed " scriptString " to this one for the virtual dir on my
server where I deployed it to
Dim scriptString As String = "<script language=JavaScript>" &
"setclock(); function setclock(){document.images.Image1.src = " &
"'http://notify1/aspclock/WebForm2.aspx';setTimeout('setclock()',1000)}<
/script>"
Page.RegisterStartupScript("setclock", scriptString)
End Sub
End Class
and here is the 2nd page (WebForm2.aspx)
Imports System.Drawing
Partial Public Class WebForm2
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Response.Cache.SetExpires(DateTime.Now.AddTicks(500))
Dim myForeBrush As Brush = Brushes.Black
Dim myFont As New Font("Times New Roman", 8, FontStyle.Regular)
Dim textHeight As Single
Dim bm As New Bitmap(120, 20)
Dim g As Graphics = Graphics.FromImage(bm)
g.Clear(Color.White)
Dim textSize As SizeF = g.MeasureString(Now.ToString, myFont)
g.DrawString(Now.ToString, myFont, myForeBrush, _
New RectangleF(0, 0, 120, 20))
Dim ms As New IO.MemoryStream
Dim arrImage() As Byte
bm.Save(ms, Imaging.ImageFormat.Bmp)
arrImage = ms.GetBuffer
Response.BinaryWrite(arrImage)
g.dispose()
End Sub
End Class
I added custom error tags in the web.config file, but I don't get any
intuitive messages - just that the app won't run. Do I need to modify
scriptString? My deploy string was
\\myservername\notify\aspclock\
the virtual dir is called notify1, so I changed scriptString to
http//notify1/aspclock/webform2.aspx.
thanks,
Rich