473,395 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Reading BLOB field into Image Web Control - Not working properly

I have some problems with the way I am showing the BLOB fields in the
Image web controls. It does work on my localhost though sometimes I
need to hit Refresh for the images to load properly. However, when I
try to access the same page from another machine or when I test the
code on a remote server the images just wouldn't show.

The page I am talking about has 3 Image web controls. In the
CodeBehind I am loading these controls by using an auxiliary aspx
page. The Code looks like this:

Main Page
=========

..
..
protected System.Web.UI.HtmlControls.HtmlInputFile banner1;
protected System.Web.UI.HtmlControls.HtmlInputFile banner2;
protected System.Web.UI.HtmlControls.HtmlInputFile banner3;
..
..
loadImage(ref imgMainBanner, "banner1");
loadImage(ref imgMainBanner, "banner2");
loadImage(ref imgMainBanner, "banner3");
..
..
private void loadImage(ref System.Web.UI.WebControls.Image imgControl,
string imageName)
{
imgURL = "GetImage.aspx?imageName=" + imageName;
imgControl.ImageUrl = imgURL;
}

GetImage.aspx
=============

string imageName = Request["imageName"];
byte[] b = businessRules.getImage(imageName);

if (b != null)
{
Response.Clear();
Response.ContentType = "image";
Response.BinaryWrite(b);
Response.Flush();
Response.Close();
}

Now here are my questions if you could kindly help me out with this:

1) Is there any other way to do this without writing the binary
contents of the BLOB into a physical file? I fear the administrators
wouldn't like the idea of end users writing files on the server any
time they hit this page.

2) Why would this solution work on my localhost (sometimes with the
help of the Refresh button) but not on remote servers?

3) Is it possible to create a file in memory and link it to the Image
web control? If so, how?

I would greatly appreciate your help on this issue. And be even more
thankful if you include some sample code.

Thanks!
Jose R. Castro
Nov 16 '05 #1
1 3284
Just to share the solution with you: While looking at one Classic ASP
page I saw that the auxiliary page used Response.End() instead of
Response.Close(). That made a big difference and the page is working
properly now.

Jose R. Castro

jr********@yahoo.com (Roberto Castro) wrote in message news:<4e**************************@posting.google. com>...
I have some problems with the way I am showing the BLOB fields in the
Image web controls. It does work on my localhost though sometimes I
need to hit Refresh for the images to load properly. However, when I
try to access the same page from another machine or when I test the
code on a remote server the images just wouldn't show.

The page I am talking about has 3 Image web controls. In the
CodeBehind I am loading these controls by using an auxiliary aspx
page. The Code looks like this:

Main Page
=========

.
.
protected System.Web.UI.HtmlControls.HtmlInputFile banner1;
protected System.Web.UI.HtmlControls.HtmlInputFile banner2;
protected System.Web.UI.HtmlControls.HtmlInputFile banner3;
.
.
loadImage(ref imgMainBanner, "banner1");
loadImage(ref imgMainBanner, "banner2");
loadImage(ref imgMainBanner, "banner3");
.
.
private void loadImage(ref System.Web.UI.WebControls.Image imgControl,
string imageName)
{
imgURL = "GetImage.aspx?imageName=" + imageName;
imgControl.ImageUrl = imgURL;
}

GetImage.aspx
=============

string imageName = Request["imageName"];
byte[] b = businessRules.getImage(imageName);

if (b != null)
{
Response.Clear();
Response.ContentType = "image";
Response.BinaryWrite(b);
Response.Flush();
Response.Close();
}

Now here are my questions if you could kindly help me out with this:

1) Is there any other way to do this without writing the binary
contents of the BLOB into a physical file? I fear the administrators
wouldn't like the idea of end users writing files on the server any
time they hit this page.

2) Why would this solution work on my localhost (sometimes with the
help of the Refresh button) but not on remote servers?

3) Is it possible to create a file in memory and link it to the Image
web control? If so, how?

I would greatly appreciate your help on this issue. And be even more
thankful if you include some sample code.

Thanks!
Jose R. Castro

Nov 16 '05 #2

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

Similar topics

7
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
4
by: mir nazim | last post by:
hi, i m facing a problem in properly accesing BLOBs from mysql db. when i display an image stored in the blob field it show some absurd characters. i think it is the problem of properly telling...
3
by: NotGiven | last post by:
I am researching the best place to put pictures. I have heard form both sides and I'd like to know why one is better than the other. Many thanks!
1
by: red | last post by:
I'm probably crazy for even trying this but I'm trying to make a script that will iterate through my databases, iterate through all the tables, and show everything on one page in forms that allow...
6
by: Pierre-Benoit | last post by:
Hi there, I've a strange problem with ado.net and an Access db. I need to create a little C# app that take the content of "ole object" field and then save it into a file. The problem is that...
1
by: sid_mulpuru | last post by:
I am trying to read data from a DB2 Blob Data type Field (using wsad 5.1.0) using getBlob() which when executed gives an SQL Exception 2005-01-07 15:48:40,506 ERROR - Error in...
2
by: Chucker | last post by:
Hi Community, I think I can store Binary Data in SQL Server but when I try to retrieve it, I always only get one byte. I think I stored my Binary Data in SQL Server in a Colum of Type Image....
1
by: yoes | last post by:
Dear all, I am very new in MySQL, I am working on image database project for my research and I have problem how to convert blob field into float in MySQL so that I can calculate the blob field...
55
ADezii
by: ADezii | last post by:
Of all the questions asked here at TheScripts, the one which appears with the most frequency relates to the storing of Graphic Images within Access. There are basically three techniques available to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
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
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
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,...

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.