Actually I was waiting for ur reply to follow a beginner like me . I used your code to enlarge the image as follows. But still have some problem . Please give me a help . The following is the code is given in aspx file. The function is not working while clicking the imagebutton. Please have a look and advice me.
With thanks
Pol
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="frmEvent.aspx.cs" Inherits="learn.frmEvent" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="#DEBA84" BorderColor="#DEBA84" DataSourceID="SqlDataSource1"
Width="1025px" AllowPaging="True" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2">
<RowStyle BorderStyle="Groove" BackColor="#FFF7E7" ForeColor="#8C4510" />
<Columns>
<asp:BoundField DataField="ObjectName" HeaderText="Name"
SortExpression="ObjectName">
<ItemStyle Width="600px" />
</asp:BoundField>
<asp:BoundField DataField="EventDate" HeaderText="Date"
SortExpression="EventDate" DataFormatString="{0:d}" />
<asp:BoundField DataField="Description" HeaderText="Description"
SortExpression="Description">
<ItemStyle Width="600px" />
</asp:BoundField>
<asp:TemplateField HeaderText="Picture">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# Eval("FilePath")%>' Width="100px" Height="100px" Style="cursor: pointer"
OnClientClick = "return LoadDiv(this.src);" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<EditRowStyle BorderStyle="Groove" />
</asp:GridView>
<script type="text/javascript">
function LoadDiv(url) {
var img = new Image();
var bcgDiv = document.getElementById("divBackground");
var imgDiv = document.getElementById("divImage");
var imgFull = document.getElementById("imgFull");
var imgLoader = document.getElementById("imgLoader");
imgLoader.style.display = "block";
img.onload = function() {
imgFull.src = img.src;
imgFull.style.display = "block";
imgLoader.style.display = "none";
};
img.src = url;
var width = document.body.clientWidth;
if (document.body.clientHeight > document.body.scrollHeight) {
bcgDiv.style.height = document.body.clientHeight + "px";
}
else {
bcgDiv.style.height = document.body.scrollHeight + "px";
}
imgDiv.style.left = (width - 650) / 2 + "px";
imgDiv.style.top = "20px";
bcgDiv.style.width = "100%";
bcgDiv.style.display = "block";
imgDiv.style.display = "block";
return false;
}
function HideDiv() {
var bcgDiv = document.getElementById("divBackground");
var imgDiv = document.getElementById("divImage");
var imgFull = document.getElementById("imgFull");
if (bcgDiv != null) {
bcgDiv.style.display = "none";
imgDiv.style.display = "none";
imgFull.style.display = "none";
}
}
</script>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ObjectName], [EventDate], [Description], [FilePath], [ObjectType] FROM [LearnPlus].[WhoAmI]
WHERE ObjectType = 'E'"></asp:SqlDataSource>
</asp:Content>