473,513 Members | 10,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trouble displaying image stored in database

hi

asp.net 2.0

I have a image (.jpeg) stored in sql server 2005 and now I want to display
it on a webpage.
So I created a webpage (Image.aspx) which just writes the buffer data to the
Response object.

On Default.aspx I use this Image.aspx for displaying the image, but no image
is displayed. All I see in the symbol saying the image couldn't be found...

Also I've placed breakpoint inside Page_Load of Image.aspx, but it wasn't
triggered. I set the breakpoint in a place where it should be triggered if
Page_load was executed.

Here is the markup in Default.aspx where I call the Image.aspx:
<img src="Image.aspx?imageId=2" />

any suggestions?
Oct 2 '08 #1
6 2179
On Oct 2, 1:31*pm, "Jeff" <it_consulta...@hotmail.com.NOSPAMwrote:
hi

asp.net 2.0

I have a image (.jpeg) stored in sql server 2005 and now I want to display
it on a webpage.
So I created a webpage (Image.aspx) which just writes the buffer data to the
Response object.

On Default.aspx I use this Image.aspx for displaying the image, but no image
is displayed. All I see in the symbol saying the image couldn't be found....

Also I've placed breakpoint inside Page_Load of Image.aspx, but it wasn't
triggered. I set the breakpoint in a place where it should be triggered if
Page_load was executed.

Here is the markup in Default.aspx where I call the Image.aspx:
<img src="Image.aspx?imageId=2" />

any suggestions?
Is image.aspx located in the same directory where default.aspx is
located?

What happens when you call your page directly as http://site/image.aspx?imageId=2

?
Oct 2 '08 #2
Your aproach should be working fine

Could it be a prblem with the path? I notice you refer to image as <img
src="Image.aspx?imageId=2" />
That means that Image.aspx and Defaul.aspx must be in the same folder. Is it
true?

PS: do not forget to set ContentType correctly in your Image.aspx.

George.

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
hi

asp.net 2.0

I have a image (.jpeg) stored in sql server 2005 and now I want to display
it on a webpage.
So I created a webpage (Image.aspx) which just writes the buffer data to
the Response object.

On Default.aspx I use this Image.aspx for displaying the image, but no
image is displayed. All I see in the symbol saying the image couldn't be
found...

Also I've placed breakpoint inside Page_Load of Image.aspx, but it wasn't
triggered. I set the breakpoint in a place where it should be triggered if
Page_load was executed.

Here is the markup in Default.aspx where I call the Image.aspx:
<img src="Image.aspx?imageId=2" />

any suggestions?
Oct 2 '08 #3
Try using a handler this is an ashx file. For a good example of how to
do this see the personal website starter kit http://www.asp.net/downloads/starter-kits/personal/

Oct 2 '08 #4
yes, Default.aspx and image.aspx is in the same directory.

when I execute Image.aspx separately I get this error:
Server Error in '/myPhotos' Application.
--------------------------------------------------------------------------------
Using themed css files requires a header control on the page. (e.g. <head
runat="server" />).
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Using themed css files
requires a header control on the page. (e.g. <head runat="server" />).

Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:
[InvalidOperationException: Using themed css files requires a header control
on the page. (e.g. <head runat="server" />).]
System.Web.UI.PageTheme.SetStyleSheet() +160
System.Web.UI.Page.OnInit(EventArgs e) +51
System.Web.UI.Control.InitRecursive(Control namingContainer) +459
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1727

This is the code in the Page_Load of Image.aspx:
public partial class Image : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
PictureDetail pic;
int imageid = Convert.ToInt32(Request.QueryString["imageId"]);
pic = SiteProvider.Picture.getPicture(imageid);

Response.ContentType = "image/jpeg";
Response.BinaryWrite(pic.FileBytes);
}
}
}

this is the markup of image.aspx: (it contains no header or body)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Image.aspx.cs"
Inherits="Image" %>
Oct 2 '08 #5
On Oct 2, 3:27*pm, "Jeff" <it_consulta...@hotmail.com.NOSPAMwrote:
yes, Default.aspx and image.aspx is in the same directory.

when I execute Image.aspx separately I get this error:
Server Error in '/myPhotos' Application.
--------------------------------------------------------------------------- -----
Using themed css files requires a header control on the page. (e.g. <head
runat="server" />).
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Using themed css files
requires a header control on the page. (e.g. <head runat="server" />).

Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:
[InvalidOperationException: Using themed css files requires a header control
on the page. (e.g. <head runat="server" />).]
* *System.Web.UI.PageTheme.SetStyleSheet() +160
* *System.Web.UI.Page.OnInit(EventArgs e) +51
* *System.Web.UI.Control.InitRecursive(Control namingContainer) +459
* *System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1727

*This is the code in the Page_Load of Image.aspx:
public partial class Image : System.Web.UI.Page
{
* * protected void Page_Load(object sender, EventArgs e)
* * {
* * * * if (!Page.IsPostBack)
* * * * {
* * * * * * PictureDetail pic;
* * * * * * int imageid = Convert.ToInt32(Request.QueryString["imageId"]);
* * * * * * pic = SiteProvider.Picture.getPicture(imageid);

* * * * * * Response.ContentType = "image/jpeg";
* * * * * * Response.BinaryWrite(pic.FileBytes);
* * * * }
* * }

}

this is the markup of image.aspx: (it contains no header or body)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Image.aspx.cs"
Inherits="Image" %>
This is because you have defined in the web.config file the theme
option <page theme="SomeTheme" />. In this case the head runat=server
is required for all pages. If you need to define themes in config and
have pages without the head element, you need to define pages in a new
folder that has a separate web.config file without the use of the
theme.
Oct 2 '08 #6
thanks, that solved my problem...
Oct 2 '08 #7

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

Similar topics

3
3628
by: Ralph Freshour | last post by:
My .php app displays an image on the web page, I notice that different ..jpg images display "funny" - apparently they all have slightly different image widths and heights yet in the image tag I...
7
2310
by: Vinay | last post by:
Hi All: I have a small application that stores images either in the database or as files (depending on the user preference). I'm in the process of providing a web interface to this application....
6
1555
by: Alec | last post by:
Newbie question. I have a database for displaying the names of bed and breakfasts searched for by the town they are in as below. <?php $result = @mysql_query ("SELECT name FROM...
7
7576
by: Jim | last post by:
I am trying to display images that are stored in a database, and I am using a repeater control. What I still use the Response.BinaryWrite method with a binding expression, if so, what with the...
3
1331
by: Irfan Akram | last post by:
Hi Guys, I am having problems displaying an image from the database, that alreday has been uoploaded successfully. The image loads in correctly, but by default it is displayed on the whole...
8
3278
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a...
7
1882
by: mosipenko | last post by:
I have a website that has articles and images. The articles are stored in one table, and if they have an image associated with them, it's stored in another table with a common id linking them. I...
0
1474
by: everdearestsunita | last post by:
hi i have to display an image whose path is stored in database.i have a table in which i have stored id,description and path of image.when i search for the path of image against the id of image...
4
2663
by: redpears007 | last post by:
Hi Again, Throwing this one out to you again as i am not getting anywhere and can find little to no information out there. I am currently displaying images (Jpegs) in access via the routine...
0
7153
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
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
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
5677
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,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.