473,503 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using anchor with DataList (asp.net 2.0 with VB)

Hello, I have created a photo gallery of thumbnails using the code below.
So far, I got the pictures to show, but now I need to figure out how a
viewer can click on the thumbnail and it opens the bigger picture. The
bigger file is the same name as the file stored in the array minus the
"_mini". So in the datalist, I would need to somehow wrap the image inside
of the anchor. Any help with this would be appreciated.

Thanks in advance

File
photo01.jpg (larger jpg)
photo01_mini.jpg (thumbnail)

Code Behind
-----------
Sub GetFiles(ByVal str00 As String)

Dim FileArray() As String
Dim arrFileList As ArrayList = New ArrayList()
Dim Item As String, strFileName As String = ""

ctrFor = 0
FileArray = Directory.GetFiles(Server.MapPath(str00), "*mini.jpg")

'-- Iterate the array items and display files
For Each Item In FileArray
strFileName = str00 & "/" & Mid(Item, InStrRev(Item, "\") + 1)
arrFileList.Add(strFileName)
Next

'Populate Repeater Control
arrFileList.TrimToSize() ' Trim the list
Me.dlstPhotoGallery.DataSource = arrFileList
Me.dlstPhotoGallery.DataBind()

End Sub
ASP.NET 2.0 Page
----------------
<asp:DataList id="dlstPhotoGallery" Runat="Server"
GridLines="Both"
CellPadding="1"
CellSpacing="3"
RepeatColumns="3"
RepeatDirection="Horizontal">
<ItemTemplate>
<asp:Image ID="imgPhotoGallery" ImageUrl='<%# Container.DataItem %>'
Runat="Server" />
</ItemTemplate>
</asp:DataList>
Feb 6 '06 #1
1 4310
Hi sck10,

Welcome to the ASPNET newsgroup.

As for the displaying image thumbnails in DataList control with links to
their actual image, I think you can consider the following means:

1. Just embed the html <a> element in DataList's ItemTemplate together with
the Image control (wrapper it), e.g:

<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<a href="http://www.asp.net">
<asp:Image ID="Image1" runat="server"
ImageUrl="~/Images/tim.JPG" />
</a>
</ItemTemplate>
</asp:DataList>

2. The ASP.NET HyperLink control support both NavigationUrl and ImageUrl
properties, and the ImageUrl property can help display an image for the
hyperlink. You can set the NavigationUrl to the actual image of the certain
thumbnail item.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Feb 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1644
by: mahsa | last post by:
H data I'm binding to the DataList is information about products in my product database. Perhaps passed in the QueryString to this page is a ProductID. I might want to make the item in the DataList...
2
3419
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
3
2848
by: vishnu | last post by:
Hi, I have a link that is coming from the database.Now if the link is empty i dont want to display in datalist .How can i do that? <td><asp:DataList id="DataList1" Runat="server"...
7
3277
by: Jim in Arizona | last post by:
I'm brand new at ajax. In fact, about 20 minutes ago was the first time I got it to work. The problem I'm having on another page did not work, however. I'm running into the following error: ...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.