473,749 Members | 2,451 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 2192
On Oct 2, 1:31*pm, "Jeff" <it_consulta... @hotmail.com.NO SPAMwrote:
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.NO SPAMwrote in message
news:OS******** ******@TK2MSFTN GP02.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.InvalidO perationExcepti on: 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:
[InvalidOperatio nException: Using themed css files requires a header control
on the page. (e.g. <head runat="server" />).]
System.Web.UI.P ageTheme.SetSty leSheet() +160
System.Web.UI.P age.OnInit(Even tArgs e) +51
System.Web.UI.C ontrol.InitRecu rsive(Control namingContainer ) +459
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +1727

This is the code in the Page_Load of Image.aspx:
public partial class Image : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
PictureDetail pic;
int imageid = Convert.ToInt32 (Request.QueryS tring["imageId"]);
pic = SiteProvider.Pi cture.getPictur e(imageid);

Response.Conten tType = "image/jpeg";
Response.Binary Write(pic.FileB ytes);
}
}
}

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.NO SPAMwrote:
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.InvalidO perationExcepti on: 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:
[InvalidOperatio nException: Using themed css files requires a header control
on the page. (e.g. <head runat="server" />).]
* *System.Web.UI. PageTheme.SetSt yleSheet() +160
* *System.Web.UI. Page.OnInit(Eve ntArgs e) +51
* *System.Web.UI. Control.InitRec ursive(Control namingContainer ) +459
* *System.Web.UI. Page.ProcessReq uestMain(Boolea n
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +1727

*This is the code in the Page_Load of Image.aspx:
public partial class Image : System.Web.UI.P age
{
* * protected void Page_Load(objec t sender, EventArgs e)
* * {
* * * * if (!Page.IsPostBa ck)
* * * * {
* * * * * * PictureDetail pic;
* * * * * * int imageid = Convert.ToInt32 (Request.QueryS tring["imageId"]);
* * * * * * pic = SiteProvider.Pi cture.getPictur e(imageid);

* * * * * * Response.Conten tType = "image/jpeg";
* * * * * * Response.Binary Write(pic.FileB ytes);
* * * * }
* * }

}

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="SomeThem e" />. 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
3642
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 have to set those properties to something - is there a way in php to get an image width and height so I can set it correctly for each image? <IMG SRC="<?php echo $php_image ?>" WIDTH="268" HEIGHT="176" BORDER="0" ALT="">
7
2339
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. 1. If the images are stored in the DB then, every an image is requested, it will need to be pulled out and a temp file created and then displayed? What is the best way to do this?
6
1568
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 site01_details WHERE town='$townsearch' AND code='sleep'"); while ($row = mysql_fetch_array($result))
7
7609
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 code look like?
3
1354
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 page. I want it to bde displayed on some part of the page. I was able to do that if I used img.ImageUrl, for images stored on my hard drive, but I want to view it from anywhere my site is sccessed, hence I decided to get it loaded directly from...
8
3302
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 picture. The ctrl in the form only displays the filename of the picture. The underlying table, when opened in table view, shows the word "package" in the field. When I double-click on either it opens the picture, but I can't get it to display. ...
7
1896
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 can pull all the information fine into labels, and if the ImagePath field is NULL, then it just doesn't show up. My problem is that when I'm trying to display the images, I get a "Conversion from type 'DBNull' to type 'String' is not valid" error...
0
1483
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 through an sql statement.it is displaying the path but unable to load the image stored at that location. kindly help with elaborated piece of code.it will be so kind
4
2680
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 set up in the article http://support.microsoft.com/kb/285820/en-us. It works fine if the image is under 1000x1000 pixels. It is set up so the user can double click to open the image in its host application.
0
8997
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8257
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3320
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 we have to send another system
2
2794
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.