I am trying to code a fairly simple web-app that displays full screen powerpoint slides that I have saved
as PNG images. I want to be able to click the right half of the image to display the next slide in the rotation, and the left side of the image to move back a slide. I have this nearly working, when I click the right side of the picture, the image changes
to the next slide in the rotation. But when I click it again, nothing happens. I can click the left side of the image, and the image changes back to the first slide, but again if I click the right side of the image again, it will advance one slide and no more.
I can move back and forth between the first and second slides with no problem, but for some reason i can't get the array index (i2) to increment more than once with the click event?? I'm sure this is a fairly simple issue, i'm not really a programmer so I
don't do this kind of thing every day. here's some of the code below:
Dim Width As String = txtWidth.Text
Dim Height As String = txtHeight.Text
Dim WidthInt As Integer = Val(Width)
Dim WidthInt2 As Integer
Dim HeightInt As Integer = Val(Height)
WidthInt2 = WidthInt / 2
Dim LeftHotSpot As New RectangleHotSpot
LeftHotSpot.Top = HeightInt
LeftHotSpot.Bottom = 0
LeftHotSpot.Left = 0
LeftHotSpot.Right = WidthInt2
LeftHotSpot.PostBackValue = "Left"
LeftHotSpot.AlternateText = "Back"
Dim RightHotSpot As New RectangleHotSpot
RightHotSpot.Top = HeightInt
RightHotSpot.Bottom = 0
RightHotSpot.Left = WidthInt2
RightHotSpot.Right = WidthInt
RightHotSpot.PostBackValue = "Right"
RightHotSpot.AlternateText = "Forward"
htmlImage.HotSpots.Add(LeftHotSpot)
htmlImage.HotSpots.Add(RightHotSpot)
htmlImage.ImageUrl = "sales/1.Png"
For Each FileName As String In System.IO.Directory.GetFiles(FolderPath)
Position = InStr(FileName, ".")
FileName = FileName.Substring(Position)
FileArray(i) = i.ToString + ".png"
i = i + 1
Next
i = i - 1
htmlImage.ImageUrl = "sales/" & FileArray(0)
End Sub
Protected Sub Click_Back(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ImageMapEventArgs) Handles htmlImage.Click
If e.PostBackValue = "Left" Then
i2 = i2 - 1
Else
i2 = i2 + 1
End If
If i2 < 0 Or i2 > i Then
i2 = 0
End If
htmlImage.ImageUrl = "sales/" + FileArray(i2)
End Sub
End Class
Form your code, I can't see the whether you have initialized and assigned a value to the variable i. If you haven't, please do it at first. Then please set a break point at the code below and see the valve of i:
i = i - 1
It seems like that there are two images in your folder. Thus, when you click the right side of the image again, it doesn't work.In addition, you can set a break point at the code below and compare the two click. That will help you to find the difference.
If e.PostBackValue = "Left" Then
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
danielsmith0...
0 Points
1 Post
why does my asp Imagemap click event only increment a variable once??
Apr 27, 2012 08:02 PM|LINK
I am trying to code a fairly simple web-app that displays full screen powerpoint slides that I have saved as PNG images. I want to be able to click the right half of the image to display the next slide in the rotation, and the left side of the image to move back a slide. I have this nearly working, when I click the right side of the picture, the image changes to the next slide in the rotation. But when I click it again, nothing happens. I can click the left side of the image, and the image changes back to the first slide, but again if I click the right side of the image again, it will advance one slide and no more. I can move back and forth between the first and second slides with no problem, but for some reason i can't get the array index (i2) to increment more than once with the click event?? I'm sure this is a fairly simple issue, i'm not really a programmer so I don't do this kind of thing every day. here's some of the code below:
Dim Width As String = txtWidth.Text Dim Height As String = txtHeight.Text Dim WidthInt As Integer = Val(Width) Dim WidthInt2 As Integer Dim HeightInt As Integer = Val(Height) WidthInt2 = WidthInt / 2 Dim LeftHotSpot As New RectangleHotSpot LeftHotSpot.Top = HeightInt LeftHotSpot.Bottom = 0 LeftHotSpot.Left = 0 LeftHotSpot.Right = WidthInt2 LeftHotSpot.PostBackValue = "Left" LeftHotSpot.AlternateText = "Back" Dim RightHotSpot As New RectangleHotSpot RightHotSpot.Top = HeightInt RightHotSpot.Bottom = 0 RightHotSpot.Left = WidthInt2 RightHotSpot.Right = WidthInt RightHotSpot.PostBackValue = "Right" RightHotSpot.AlternateText = "Forward" htmlImage.HotSpots.Add(LeftHotSpot) htmlImage.HotSpots.Add(RightHotSpot) htmlImage.ImageUrl = "sales/1.Png" For Each FileName As String In System.IO.Directory.GetFiles(FolderPath) Position = InStr(FileName, ".") FileName = FileName.Substring(Position) FileArray(i) = i.ToString + ".png" i = i + 1 Next i = i - 1 htmlImage.ImageUrl = "sales/" & FileArray(0) End Sub Protected Sub Click_Back(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ImageMapEventArgs) Handles htmlImage.Click If e.PostBackValue = "Left" Then i2 = i2 - 1 Else i2 = i2 + 1 End If If i2 < 0 Or i2 > i Then i2 = 0 End If htmlImage.ImageUrl = "sales/" + FileArray(i2) End Sub End ClassCatherine Sh...
All-Star
23373 Points
2490 Posts
Microsoft
Re: why does my asp Imagemap click event only increment a variable once??
May 04, 2012 07:16 AM|LINK
Hi danielsimth00,
Form your code, I can't see the whether you have initialized and assigned a value to the variable i. If you haven't, please do it at first. Then please set a break point at the code below and see the valve of i:
It seems like that there are two images in your folder. Thus, when you click the right side of the image again, it doesn't work.In addition, you can set a break point at the code below and compare the two click. That will help you to find the difference.
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store