A1VBCode Forums

Previous Next Buttons


http://www.a1vbcode.com/vbforums/Topic26706.aspx

By shers - 1/10/2009

Hi,

I have some images that has to be displayed on a form from a dynamic folder using control array. The controls display 5X3, that is 15 images on one form. How do I display the next set of images using Next button, and go back to the previous set using the Previous button, if there are more than 15 files in the folder.

Thanks

By amanz90 - 8/7/2009

hi,

my next button works on the second click...eg:if i click next the page will just reload and then i click anything else on the page then the next button works

same for previous.... really need some help

this is the code i have

----------------------------------------------------------------------------------------------------------------------







Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then

p = 0

Session("p") = p 'p

End If

nsi = Session("nsi") 'no of images

lp = nsi / 15 'last page

Session("lp") = lp

pagechk()

p = Session("p")

lblpn.Text = p & "/" & lp

display()



End Sub



Dim j, x(15) As Int32



Private Sub pagechk()

lp = Session("lp")

p = Session("p")

If p = lp Then

btnnext.Enabled = False

btnprv.Enabled = True

If p > 0 Then

btnprv.Enabled = True

Else

btnprv.Enabled = False

End If

Else

btnnext.Enabled = True

If p > 0 Then

btnprv.Enabled = True

Else

btnprv.Enabled = False

End If

End If

End Sub



Private Sub display()

p = Session("p")

j = p * 15

For i As Int32 = 1 To 15

j += 1

x(i) = j

Next

imgsuits1.ImageUrl = "~/images/Suits thumbs/p" & x(1) & ".jpg"

imgsuits2.ImageUrl = "~/images/Suits thumbs/p" & x(2) & ".jpg"

imgsuits3.ImageUrl = "~/images/Suits thumbs/p" & x(3) & ".jpg"

imgsuits4.ImageUrl = "~/images/Suits thumbs/p" & x(4) & ".jpg"

imgsuits5.ImageUrl = "~/images/Suits thumbs/p" & x(5) & ".jpg"

imgsuits6.ImageUrl = "~/images/Suits thumbs/p" & x(6) & ".jpg"

imgsuits7.ImageUrl = "~/images/Suits thumbs/p" & x(7) & ".jpg"

imgsuits8.ImageUrl = "~/images/Suits thumbs/p" & x(8) & ".jpg"

imgsuits9.ImageUrl = "~/images/Suits thumbs/p" & x(9) & ".jpg"

imgsuits10.ImageUrl = "~/images/Suits thumbs/p" & x(10) & ".jpg"

imgsuits11.ImageUrl = "~/images/Suits thumbs/p" & x(11) & ".jpg"

imgsuits12.ImageUrl = "~/images/Suits thumbs/p" & x(12) & ".jpg"

imgsuits13.ImageUrl = "~/images/Suits thumbs/p" & x(13) & ".jpg"

imgsuits14.ImageUrl = "~/images/Suits thumbs/p" & x(14) & ".jpg"

imgsuits15.ImageUrl = "~/images/Suits thumbs/p" & x(15) & ".jpg"

End Sub



Protected Sub btnprv_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnprv.Click

p = Session("p")

p = p - 1

Session("p") = p

Session("bt") = 1

End Sub



Protected Sub btnnext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnnext.Click

p = Session("p")

p = p + 1

Session("p") = p

Session("bt") = 1

End Sub



Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload

If Session("bt") = 1 Then

Session("bt") = 0

Else

Session("p") = 0

Session("bt") = 0

End If

End Sub