Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How To Retrieve and display more than 1 images in aspx page from database without using HttpHandler??
Posted

This is just an idea.

1. you can dump/save the images into the temporary folder and link those images into the repeater control. the repeater control has image template. if you worry about the temporary images, you can create cronjob to delete.

2. if you don't want to save the images in the temp folder. you can also convert/encode the images into base64 string and embed those base64 into the html. try to search in google "base 64 images in html".

3. you can also create a large image which I don't recommend, and draw each image vertically.

I usually use the 1st method. if you have a problem with the cronjob, you can also use the OnRemoveCallback of CacheItem to delete the temporary images. sample code below.
C#
protected void Page_Load(object sender, EventArgs e)
{
    string tempFilePath = "C:\\Imagepath\\image1.jpg";

    DeleteFile(tempFilePath);
}

private void DeleteFile(string fileName)
{
    HttpContext.Current.Cache.Add(fileName, fileName, null,
                                  DateTime.Now.AddMinutes(5),
                                  Cache.NoSlidingExpiration,
                                  CacheItemPriority.Normal,
                                  (key, value, reason) =>
                                  {
                                      try
                                      {
                                          File.Delete(Convert.ToString(value));
                                      }
                                      catch { }
                                  });

}
 
Share this answer
 
Comments
Member 8499806 17-Feb-12 5:29am    
I have no idea about how to create temporary file. so, please give full code..
I can retrieve a image byte[] from database.
Please Help...
Hi,
Go through the following-

SQL Database Image Storage & Easy Thumbnails[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900