 |
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

May 10th, 2004, 12:01 PM
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
img src an aspx location??
I viewed source for some aspx webpage. I got interested in a picture on that page, which is basically in form of a table that contains some information. In the page code that contains the image, the img source of that table was set to another aspx url.
So here is my question: can you specify another aspx location for an img source? How do you handle the size of the image and such.
Thanks.
|

May 10th, 2004, 12:25 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
But was the "table" still a picture?
It's quite possible for an ASPX page to return an image. By setting the ContentType of the page to an image type, the browser will see the output of the ASPX page as a regular image. The extension doesn't really matter for the browser; it's the type of data (the ContentType) that's important.
You could do something like this, where the image comes from a blob in the database:
Code:
Response.ContentType = myDataReader.Item("ContentType")
Response.BinaryWrite(myDataReader.Item("TheImage"))
You can control the image's properties like you normally would, using HTML attributes and CSS.
Cheers,
Imar
|

May 10th, 2004, 12:40 PM
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks Imar. Appreciate the quick response. A couple of more questions.
1) In an asp.net app, in what section (like page load and such) would you set the content type of the response to be an image.
2) Once that's done, would the page content set up like a regular aspx page be provided to the client as an image, or you'd actually have to return an image in the response?
Thanks.
|

May 10th, 2004, 12:51 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Here is an example: (image.aspx)
<% Page ContentType="image/gif" %>
<% Import namespace="System.Drawing" %>
<% Import namespace="System.Drawing.Imaging" %>
<Script Runat="server">
Sub Page_Load
Dim objBitmap as Bitmap
Dim intCounter As Integer
Dim objRandom As Random
'creates the bitmap
objBitmap = New Bitmap(400, 200)
'Sets it to 1000 pixels
objRandom = New Random
For intCounter = 1 To 1000
objBitmap.SetPixel(objRandom.Next(400), objRandom(200), Color.Red)
Next
objBitmap.Save(Response.OutputStream, ImageFormat.Gif)
End Sub
</Script>
In another page:
<img src="image.aspx"
|

May 10th, 2004, 01:32 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi texasraven,
Like Stu showed you, a good place is the Load event of the page. Because the browser will see the ASPX page as an image, you cannot return anything else than just the image.
If your page contains other output, like HTML, you'll get an error. To fix that, call Response.Clear at the start of the Load method, and Response.End at the end. This way, you can be sure no output is sent to the browser.
Stu9820: were you ever able to fix your RegisterArrayDeclaration issue??
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

May 10th, 2004, 02:52 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
I was trying to use it to validate a checkboxlist and then I realized that a CheckBoxList is optional so I quit working on it. But I still couldn't get anything other than the firstname to validate properly.
|

May 10th, 2004, 03:23 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hmmmm, yeah, these kind of validation "hacks" can be tricky sometimes....
But it seems it's not an issue anymore??
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Hands Clean by Alanis Morissette (From the album: Under Rug Swept) What's This?
|

May 10th, 2004, 03:54 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
I'll wait for 2.0 which I've read will have validation controls for CheckBoxLists. :)
|

May 10th, 2004, 03:56 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Ha, yes. If only it was available now; things would be so much easier.
I am not patient enough to wait so long..... :-(
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: The Unforgiven by Metallica (Track 4 from the album: Metallica) What's This?
|

May 10th, 2004, 04:00 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Me either. I was hoping for a Summer 2004 release but I've read that it will now be 2005 when "Yukon" (codename for SQL Server for those who are following along) ships...
|
|
 |