There are two javascript script files
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JQueryLightBoxExample.aspx.cs" Inherits="JQueryLightBoxExample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>JQueryLightBox Example</title>
<link rel="stylesheet" type="text/css" href="../style-projects-jquery.css" />
<!-- Arquivos utilizados pelo jQuery lightBox plugin -->
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" />
<script type="text/javascript">
$(function() {
$('#gallery a').lightBox();
});
</script>
<style type="text/css">
/* jQuery lightBox plugin - Gallery style */
#gallery {
background-color: #444;
padding: 2px;
width: 800px;
}
#gallery ul { list-style: none; }
#gallery ul li { display: inline; }
#gallery ul img {
border: 5px solid #3e3e3e;
border-width: 5px 5px 20px;
}
#gallery ul a:hover img {
border: 5px solid #fff;
border-width: 5px 5px 20px;
color: #fff;
}
#gallery ul a:hover { color: #fff; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="gallery">
<asp:DataList ID="FeaturedList" runat="server" RepeatLayout="Table" Width="100%" RepeatColumns="5">
<ItemTemplate>
<div>
<ul>
<li>
<a href='<%#getHREF(Container.DataItem)%>' title='<%# DataBinder.Eva
(Container.DataItem, "Rep_FirstName")%>'>
<img src='<%# getSR
(Container.DataItem) %>' align="top" title='<%# DataBinder.Eval(Container.DataItem, "Rep_FirstName")%>' height="100" width="100">
</a>
</li>
</ul>
</div>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
Code Behind :
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Data.SqlClient;
public partial class JQueryLightBoxExample : System.Web.UI.Page
{
SqlConnection conn;
SqlCommand cmd;
DataTable dataTable;
SqlDataAdapter sqlAdapter;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetImagesFromDatabase();
}
}
public void GetImagesFromDatabase()
{
conn = new SqlConnection();
conn.ConnectionString = "Data Source=RAJ-PC\\;Initial Catalog=ModelingCorner;Integrated Security=True";
if (conn.State == ConnectionState.Closed)
conn.Open();
cmd = new SqlCommand();
cmd.CommandText = "Select top 5 * from tbl_Rep_Profile";
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
dataTable = new DataTable();
sqlAdapter = new SqlDataAdapter();
sqlAdapter.SelectCommand = cmd;
sqlAdapter.Fill(dataTable);
FeaturedList.DataSource = dataTable.DefaultView;
FeaturedList.DataBind();
}
public string getHREF(object sURL)
{
DataRowView dRView = (DataRowView)sURL;
return ResolveUrl("~/Rep_Images/" + dRView["UserId"].ToString() + "/" + dRView["Rep_Id"].ToString() + "/" + "Real" + "/" + dRView["Rep_Img_Name"].ToString());
}
public string getSRC(object imgSRC)
{
DataRowView dRView = (DataRowView)imgSRC;
return ResolveUrl("~/Rep_Images/" + dRView["UserId"].ToString() + "/" + dRView["Rep_Id"].ToString() + "/" + "Thumbnail" + "/" + "M" + "/" + dRView["Rep_Img_Name"].ToString());
}
}
Now run the application:

Image 1.
When you click on an image then the picture will expand. When you roll over on top of image then you can see PREV and NEXT, Image Title, Image Counting and Close button.

Image 2.

Image 3.
I have attached javascript files and .css files. Write a comment if you have any questions or comments.

Mehmet KuzuPosted Mar 5, 2019, 1:34 AM
Good sample, do you have how to save a picure or path adress as guid to mssql
said djelmoPosted Aug 25, 2015, 3:31 PM
dont work, image open in new window ?
parul maheshwariPosted Nov 21, 2012, 6:44 AM
in css, zoom: 1 attribute is not working with IE and Mozila firefox.
brian streeterPosted Aug 3, 2012, 11:43 PM
How did you store the images and what kind of naming convention did you use in the SQL DB? Or I should say what does Rep_ID and Rep_Img_Name consist of? Any help would be appreciated.
Nirbhay SinghPosted Oct 19, 2011, 11:31 PM
Can you please let me know about tables column return ResolveUrl("~/Rep_Images/" + dRView["UserId"].ToString() + "/" + dRView["Rep_Id"].ToString() + "/" + "Real" + "/" + dRView["Rep_Img_Name"].ToString());
Mahesh ChandPosted Jan 5, 2011, 11:24 AM
Good work. Do you need to install JQueryLightBox or can the DLL be a part of this project?
Spyros PonarisPosted Jan 5, 2011, 8:51 AM
It is really nice . keep coding