473,386 Members | 1,705 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,386 software developers and data experts.

How to mix ContentType in same page?


If I would like to place in a page both text and image,
is it possible? And, in case, how would I correct the following
code ?

'tetx
Response.ContentType = "text.html"
Response.Write("Hello hello")

'image
Response.ContentType = "image/jpeg"
Dim b As New Bitmap(200, 200)
Dim g As Graphics = Graphics.FromImage(b)
g.FillRectangle(New SolidBrush(Color.Red), 0, 0, 200, 200)
b.Save(Response.OutputStream, ImageFormat.Jpeg)
g.Dispose()
b.Dispose()

Sep 22 '06 #1
8 1632
The text needs to be output into a regular HTML page.
That HTML page needs to have a regular image tag, such as <img
src="MyImage.aspx">

Then in MyImage.aspx you need to output the image with content type
image/jpeg as you noted.

This can only be done with two pages as I've described. One page will not
work. IE6 does not support doing two content types in a single page.

Here's more info:
http://SteveOrr.net/articles/ImproveYourImages.aspx

--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM
http://SteveOrr.net
<pa***********@libero.itwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
>
If I would like to place in a page both text and image,
is it possible? And, in case, how would I correct the following
code ?

'tetx
Response.ContentType = "text.html"
Response.Write("Hello hello")

'image
Response.ContentType = "image/jpeg"
Dim b As New Bitmap(200, 200)
Dim g As Graphics = Graphics.FromImage(b)
g.FillRectangle(New SolidBrush(Color.Red), 0, 0, 200, 200)
b.Save(Response.OutputStream, ImageFormat.Jpeg)
g.Dispose()
b.Dispose()

Sep 22 '06 #2
The text needs to be output into a regular HTML page.
That HTML page needs to have a regular image tag, such as <img
src="MyImage.aspx">

Then in MyImage.aspx you need to output the image with content type
image/jpeg as you noted.

This can only be done with two pages as I've described. One page will not
work. IE6 does not support doing two content types in a single page.
If I understand it correctly, it's not an error (or shortcoming) on the
part of IE, but a limitation of the HTTP protocol. This means that NO
browser can handle "double content".

Hans Kesting
Sep 22 '06 #3
this can be done with most modern browsers, but not ie (until version 7).

<img src="data:image/gif;base64,thisIsbase64ImageContent">

-- bruce (sqlwork.com)

<pa***********@libero.itwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
>
If I would like to place in a page both text and image,
is it possible? And, in case, how would I correct the following
code ?

'tetx
Response.ContentType = "text.html"
Response.Write("Hello hello")

'image
Response.ContentType = "image/jpeg"
Dim b As New Bitmap(200, 200)
Dim g As Graphics = Graphics.FromImage(b)
g.FillRectangle(New SolidBrush(Color.Red), 0, 0, 200, 200)
b.Save(Response.OutputStream, ImageFormat.Jpeg)
g.Dispose()
b.Dispose()

Sep 22 '06 #4
Thanks Steve.
I downloaded your code. Beautiful !

Ciao,

-P

Steve C. Orr [MVP, MCSD] ha scritto:
The text needs to be output into a regular HTML page.
That HTML page needs to have a regular image tag, such as <img
src="MyImage.aspx">

Then in MyImage.aspx you need to output the image with content type
image/jpeg as you noted.

This can only be done with two pages as I've described. One page will not
work. IE6 does not support doing two content types in a single page.

Here's more info:
http://SteveOrr.net/articles/ImproveYourImages.aspx

--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM
http://SteveOrr.net
<pa***********@libero.itwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...

If I would like to place in a page both text and image,
is it possible? And, in case, how would I correct the following
code ?

'tetx
Response.ContentType = "text.html"
Response.Write("Hello hello")

'image
Response.ContentType = "image/jpeg"
Dim b As New Bitmap(200, 200)
Dim g As Graphics = Graphics.FromImage(b)
g.FillRectangle(New SolidBrush(Color.Red), 0, 0, 200, 200)
b.Save(Response.OutputStream, ImageFormat.Jpeg)
g.Dispose()
b.Dispose()
Sep 22 '06 #5
1. You can create a sample aspx page like below

<html>
<body>
<table>
<tr>
<td>
<asp:Label id=lblHelloWorld runat=server>Hello
World<asp:label>
</td>
</tr>
<tr>
<td>
<img src=GetImage.aspx?ImagID="imageName">
</td>
</tr>
</table>
</body>
</html>

2. write a new page called GetImage.aspx on page load of this page
if(Request["ImageID"] != null)
Response.WriteFile("..images/Request["ImageID"] ); //I assume you
stored all your image in image folder under the root.
<pa***********@libero.itwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
>
If I would like to place in a page both text and image,
is it possible? And, in case, how would I correct the following
code ?

'tetx
Response.ContentType = "text.html"
Response.Write("Hello hello")

'image
Response.ContentType = "image/jpeg"
Dim b As New Bitmap(200, 200)
Dim g As Graphics = Graphics.FromImage(b)
g.FillRectangle(New SolidBrush(Color.Red), 0, 0, 200, 200)
b.Save(Response.OutputStream, ImageFormat.Jpeg)
g.Dispose()
b.Dispose()

Sep 22 '06 #6
Thank you Baski for the nice and clear example,

it is very useful to have it.

-P
Baski ha scritto:
1. You can create a sample aspx page like below

<html>
<body>
<table>
<tr>
<td>
<asp:Label id=lblHelloWorld runat=server>Hello
World<asp:label>
</td>
</tr>
<tr>
<td>
<img src=GetImage.aspx?ImagID="imageName">
</td>
</tr>
</table>
</body>
</html>

2. write a new page called GetImage.aspx on page load of this page
if(Request["ImageID"] != null)
Response.WriteFile("..images/Request["ImageID"] ); //I assume you
stored all your image in image folder under the root.
<pa***********@libero.itwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...

If I would like to place in a page both text and image,
is it possible? And, in case, how would I correct the following
code ?

'tetx
Response.ContentType = "text.html"
Response.Write("Hello hello")

'image
Response.ContentType = "image/jpeg"
Dim b As New Bitmap(200, 200)
Dim g As Graphics = Graphics.FromImage(b)
g.FillRectangle(New SolidBrush(Color.Red), 0, 0, 200, 200)
b.Save(Response.OutputStream, ImageFormat.Jpeg)
g.Dispose()
b.Dispose()
Sep 22 '06 #7
If I understand it correctly, it's not an error (or shortcoming) on the
part of IE, but a limitation of the HTTP protocol. This means that NO
browser can handle "double content".
Actually most other browsers do support embedded images, just not IE6...

--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM
http://SteveOrr.net
Sep 24 '06 #8
>If I understand it correctly, it's not an error (or shortcoming) on the
>part of IE, but a limitation of the HTTP protocol. This means that NO
browser can handle "double content".

Actually most other browsers do support embedded images, just not IE6...
You learn something new every day ...

Hans Kesting
Sep 25 '06 #9

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

Similar topics

2
by: Kamyk | last post by:
Hello all! I have the following problem. I have both text content and image content of the web page created in ASP language. How to do combine these two different types on the page. When I use...
0
by: Eyal Zinder | last post by:
Hello to all.. I'm trying to format an excel page by creating html tables on the fly through Response.ContentType = "application/vnd.ms-excel" . I now produce reports in html format by processing...
0
by: Lone | last post by:
Hi all, Im trying to stream an RealPlayer file to the client. In classis asp, the code was as such: <% Response.Buffer=True Response.ContentType="audio/x-pn-realaudio" %>...
0
by: Microsoft NewsGroups | last post by:
I am creating a TAB delimited file with .XLS extention using the Response.ContentType = "application/ms-excel" method. Normally I would place this on it's own form and delete all the HTML in the...
3
by: letuce dance | last post by:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender,...
6
by: Chris3000 | last post by:
I got this in my code : Response.ContentType = "image/jpg" or image/jpeg or gif or bmp I cant open this asp page with internet explorer. I get a message error: Internet explorer cannot...
1
by: rguarnieri | last post by:
Hi!, I'm using Visual Studio 6.0 and I'm trying to open an asp page like a .pdf file, I used Response.ContentType="application/pdf" in my asp page but it doesn't work This is an example: <%@...
4
by: Bjorn Sagbakken | last post by:
With ASP.NET 2.0 I'm trying to display the pdf file directly in the client browser, but I only get a download dialogue box. Downloading the file works fine, but I want to view the PDF directly. ...
1
by: greatvishal | last post by:
Hi, I have a page where I am trying to render a pdf file using response.contenttype = "application/pdf". when the page has rendered, I need to launch a javascript command to launch the window's...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.