<img id="image1" runat="server" src="" alt="" height="100" width="100" onclick="ShowDialog1()"/>
<div id="dialog1" title="Full Image View" style="display: none">
<img id="Img1" runat="server" />
</div>
function ShowDialog1() {
$("#dialog1").dialog();
}
protected void LoadImage1()
{
SqlCommand cmd = new SqlCommand("sps_getimage", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@flag", 1);
cmd.Parameters.AddWithValue("@ad_id", ad_id);
con.Open();
SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.SequentialAccess);
if (reader.HasRows)
{
reader.Read();
MemoryStream memory = new MemoryStream();
long startIndex = 0;
const int ChunkSize = 256;
while (true)
{
byte[] buffer = new byte[ChunkSize];
long retrievedBytes = reader.GetBytes(0, startIndex, buffer, 0, ChunkSize);
memory.Write(buffer, 0, (int)retrievedBytes);
startIndex += retrievedBytes;
if (retrievedBytes != ChunkSize)
break;
}
byte[] data = memory.ToArray();
memory.Dispose();
image1.Src = "data:image/png;base64," + Convert.ToBase64String(data);
Img1.Src = "data:image/png;base64," + Convert.ToBase64String(data);
}
con.Close();
}