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.Binary Write method with a
binding expression, if so, what with the code look like? 7 7609
Hi Jim,
Can it be so easy? Think I wrong now?
<ItemTemplate >
<asp:Image ID="myImage" Runat="Server" ImageUrl='<%#
Container.DataI tem("myColumn") %>'/>
</ItemTemplate>
If I had wrong, want you create the Image or the ImageUrl in Code-Behind?
Hi Jim,
Can it be so easy? Think I wrong now?
<ItemTemplate >
<asp:Image ID="myImage" Runat="Server" ImageUrl='<%#
Container.DataI tem("myColumn") %>'/>
</ItemTemplate>
If I had wrong, want you create the Image or the ImageUrl in Code-Behind?
Since you refer to the Response.Binary Write method it sounds like you have
your image stored as a BLOb/image/binary column in your db table, and not
simply a path to a jpg or gif in the file system.
If that's the case you need an aspx page that takes an image identifier as a
parameter, gets the BLOb column binary content from the db and delivers it
as the HTTP response using the Response.Binary Write method.
Your page also needs to add HTTP headers to tell the browser what kind of
content is coming, known as the "MIME Type", e.g. image/gif or image/jpeg.
In your repeater you add an image (<IMG ... />) with its souce set to the
name of your BLOb handler, and passing the image identifier as a parameter.
<ItemTemplate >
<asp:Image ID="myImage" Runat="Server"
ImageUrl='myBLO bHandler.aspx?i d=<%#
Container.DataI tem("myImageIde ntifier") %>' />
</ItemTemplate>
I've done this with all sorts of file content, MP3, Word, Excel, PDF, even
HTML, as well as gif, jpg and png images to avoid hassle over file system
resources and write permissions, etc.
"Jim" <Ji*@discussion s.microsoft.com > wrote in message
news:BB******** *************** ***********@mic rosoft.com... 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.Binary Write method with a binding expression, if so, what with the code look like?
Since you refer to the Response.Binary Write method it sounds like you have
your image stored as a BLOb/image/binary column in your db table, and not
simply a path to a jpg or gif in the file system.
If that's the case you need an aspx page that takes an image identifier as a
parameter, gets the BLOb column binary content from the db and delivers it
as the HTTP response using the Response.Binary Write method.
Your page also needs to add HTTP headers to tell the browser what kind of
content is coming, known as the "MIME Type", e.g. image/gif or image/jpeg.
In your repeater you add an image (<IMG ... />) with its souce set to the
name of your BLOb handler, and passing the image identifier as a parameter.
<ItemTemplate >
<asp:Image ID="myImage" Runat="Server"
ImageUrl='myBLO bHandler.aspx?i d=<%#
Container.DataI tem("myImageIde ntifier") %>' />
</ItemTemplate>
I've done this with all sorts of file content, MP3, Word, Excel, PDF, even
HTML, as well as gif, jpg and png images to avoid hassle over file system
resources and write permissions, etc.
"Jim" <Ji*@discussion s.microsoft.com > wrote in message
news:BB******** *************** ***********@mic rosoft.com... 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.Binary Write method with a binding expression, if so, what with the code look like?
Thanks Brian, but I am a little confused on how to use the
Response.Binary Write from the code behind when the method is called from the
repeater control. What would the method look like in the code behind?
Thanks for your help,
Jim
"Brian Lowe" wrote: Since you refer to the Response.Binary Write method it sounds like you have your image stored as a BLOb/image/binary column in your db table, and not simply a path to a jpg or gif in the file system.
If that's the case you need an aspx page that takes an image identifier as a parameter, gets the BLOb column binary content from the db and delivers it as the HTTP response using the Response.Binary Write method.
Your page also needs to add HTTP headers to tell the browser what kind of content is coming, known as the "MIME Type", e.g. image/gif or image/jpeg.
In your repeater you add an image (<IMG ... />) with its souce set to the name of your BLOb handler, and passing the image identifier as a parameter.
<ItemTemplate > <asp:Image ID="myImage" Runat="Server" ImageUrl='myBLO bHandler.aspx?i d=<%# Container.DataI tem("myImageIde ntifier") %>' /> </ItemTemplate>
I've done this with all sorts of file content, MP3, Word, Excel, PDF, even HTML, as well as gif, jpg and png images to avoid hassle over file system resources and write permissions, etc.
"Jim" <Ji*@discussion s.microsoft.com > wrote in message news:BB******** *************** ***********@mic rosoft.com...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.Binary Write method with a binding expression, if so, what with the code look like?
"Jim" <Ji*@discussion s.microsoft.com > wrote in message
news:FC******** *************** ***********@mic rosoft.com... Thanks Brian, but I am a little confused on how to use the Response.Binary Write from the code behind when the method is called from the repeater control. What would the method look like in the code behind?
Step back. There's no need to do it all in one page. In any web page the
HTML gets served in response to the first request for the URL and the
browser then makes further requests to collect any referenced resources,
like stylesheets, scripts, or images.
We're dealing with two separate aspx pages now.
You have one page, lets call it mainpage.aspx that includes a repeater that
includes repeated instances of the image... <ItemTemplate > <asp:Image ID="myImage" Runat="Server" ImageUrl='myBLO bHandler.aspx?i d=<%# Container.DataI tem("myImageIde ntifier") %>' /> </ItemTemplate>
The only code that gets called in this page is the databinding to get the
<img ... /> tag rendered once for each data row in the data source. This
results in:
<img src='myBLObHand ler.aspx?id=1' />
<img src='myBLObHand ler.aspx?id=2' />
<img src='myBLObHand ler.aspx?id=... ' />
<img src='myBLObHand ler.aspx?id=n' />
This goes out as the normal text output to the response stream. The
receiving browser renders the HTML and picks up references to source files
for four images so makes requests back to your server for each image.
This is where the second file comes in.
You need an aspx page called myBLObHandler.a spx to handle the request.
This page has no HTML, its purely code behind.
The code takes the id given in the parameters, uses it to extract the
required binary content from the db, and then streams that binary content
back using Response.Binary Write()
Clear?
Brian Lowe
---------@
OK. I understand that and why it works. However, when I use the following
code that brings back the content type and image data from the database in a
data set it only displays a blank image with the dreaded red "x".
DataSet ds = new DataSet ();
ds =
objTest.Retriev eTestImage(Conv ert.ToInt32(Req uest.QueryStrin g["id"]));
foreach (DataRow dr in ds.Tables [0].Rows) {
Response.Conten tType= dr ["strType"].ToString();
Response.Binary Write((byte [])dr ["imgTestIma ge"]);
}
I know that there is data in all of my fields, because I printed them out as
a string in the browser except for the image data where I printed out the
length of the byte array. Any ideas?
"Brian Lowe" wrote: "Jim" <Ji*@discussion s.microsoft.com > wrote in message news:FC******** *************** ***********@mic rosoft.com... Thanks Brian, but I am a little confused on how to use the Response.Binary Write from the code behind when the method is called from the repeater control. What would the method look like in the code behind?
Step back. There's no need to do it all in one page. In any web page the HTML gets served in response to the first request for the URL and the browser then makes further requests to collect any referenced resources, like stylesheets, scripts, or images.
We're dealing with two separate aspx pages now.
You have one page, lets call it mainpage.aspx that includes a repeater that includes repeated instances of the image...
<ItemTemplate > <asp:Image ID="myImage" Runat="Server" ImageUrl='myBLO bHandler.aspx?i d=<%# Container.DataI tem("myImageIde ntifier") %>' /> </ItemTemplate>
The only code that gets called in this page is the databinding to get the <img ... /> tag rendered once for each data row in the data source. This results in: <img src='myBLObHand ler.aspx?id=1' /> <img src='myBLObHand ler.aspx?id=2' /> <img src='myBLObHand ler.aspx?id=... ' /> <img src='myBLObHand ler.aspx?id=n' />
This goes out as the normal text output to the response stream. The receiving browser renders the HTML and picks up references to source files for four images so makes requests back to your server for each image.
This is where the second file comes in.
You need an aspx page called myBLObHandler.a spx to handle the request.
This page has no HTML, its purely code behind.
The code takes the id given in the parameters, uses it to extract the required binary content from the db, and then streams that binary content back using Response.Binary Write()
Clear?
Brian Lowe ---------@ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dalan |
last post by:
At first I was not certain what could cause Access 97 from displaying
most jpeg images, but not all. After further testing, it seemed that
all original images of less than 275 pixels per inch or less would
display, but those close to 300 pixels/inch or greater would not (MS
Access cannot recognize the file format xxx.jpg). The larger, original
images were scanned and saved as .bmp (at 300 dpi producing a 15MB
file). Then the images were...
|
by: marvin |
last post by:
Hi,
I am trying to display images in a repeater from a SQL database and do
some transformations on the image prior to displaying them (such as
thumbnail with a shadow). The problem is I can't seem to get the data
passed to the handler.
The following is the code that I have so far.
In the ViewPics.aspx file I have...
|
by: Ryan Harvey |
last post by:
Hi all,
I have written a web user control that contains a repeater control. the
ItemTemplate for this control is basically 6 Hyperlinks in a row, that are
dynamically allocated one of 7 gif images as the ImageURL of the Hyperlink.
When a load the page with the controls on it works fine, but sometimes the
images are broken, but if i hit refresh i get random selections of the gifs
appearing and not appearing. if i hit Back button to a page...
|
by: gemel |
last post by:
I am developing an application that uses SQL 2000 as my source of
images. I have successfully created the code to load the images onto
the SQL Server and also to retrieve the images into a dataset. I
tested the application by populating a Dataset with the images from
SQL Server and rendered just one of the images by using a bitmap and
inserting the resulting stream into the response stream as a Jpeg
format.
My next move was to bind this...
|
by: Imran Aziz |
last post by:
Hello all,
I am populating the contents of a repeater control using a database query.
In the repeater control I have a link , which I want to display or not based
on the current logged in user. I have a asp:panel surrounding this link and
evaluate its value using the code below.
<asp:panel ID="Panel5" runat=server Visible='<%#
((DataBinder.Eval(Container.DataItem, "nUserID")).ToString() !=
ViewState.ToString() ) %>' Wrap="false" >
| |
by: Patrick.O.Ige |
last post by:
I want to have a rollover image on an hyperlink inside a Repeater control
but when i run the page i get
"Image1 is undefined"
Any ideas?
I have a Hyperlink and an Image control in a repeater like below:-
<ItemTemplate>
<tr width="150px" style="cursor:hand"
onmouseover="style.backgroundColor='#c0c0c0';"
onmouseout="style.backgroundColor=''" bordercolor="#000000">
|
by: Charlie |
last post by:
Hi:
Is it possible to databind an image in Repeater Control? I see support for
it in GridView, but not in Repeater control. There is another way to do
this, but would rather go with new controls.
Thanks,
Charlie
|
by: Nobody |
last post by:
I'm working on an e-commerce type site where I have a bunch of categorized
items... once you drill down to the items page, I show the list of items
with a "preview picture". When you click on the item itself, there are 1 to
n detail pictures. What is the best way to do this?
1) Should I store the images in the database?
2) seems easier to store them in the /images directory, but then backing up,
restoring or scaling the database becomes...
|
by: Jeff |
last post by:
hi
asp.net 2.0
On my webpage I want to display a list of images. Most proparly display the
list horizontal
Sometimes I want only one image to be displayed and sometimes maybe 10
images.
It's the same image I want to be displayed several times in the list.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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,...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |