Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » .NET Programming » C# » Previous Next Buttons


Previous Next ButtonsExpand / Collapse
Author
Message
Posted 1/11/2009 3:18:07 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 8/31/2013 5:00:27 AM
Posts: 66, Visits: 170
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

Post #26706
Posted 1/15/2009 1:18:28 PM
Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: 5/22/2014 12:38:03 PM
Posts: 370, Visits: 211
You could use a datagrid or repeater control.  These have paging capabilities and can display images.  Or build your custom methods using the fileinfo class and iterating the collection.  Heck you might even be able to use the fileinfo class as a datasource to bind to a datagrid! Come up with some code and I give you a hand.

Good Luck

TallOne

Post #26741
Posted 8/8/2009 12:19:14 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 8/8/2009 4:28:03 AM
Posts: 3, Visits: 13
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
----------------------------------------------------------------------------------------------------------------------


[quote]
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
[/quote]
Post #28006
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 1:11pm