Wrox Programmer Forums
|
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
 
Old May 10th, 2004, 12:01 PM
Authorized User
 
Join Date: Aug 2003
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

 
Old May 10th, 2004, 12:25 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
 
Old May 10th, 2004, 12:40 PM
Authorized User
 
Join Date: Aug 2003
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old May 10th, 2004, 12:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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"

 
Old May 10th, 2004, 01:32 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old May 10th, 2004, 02:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.

 
Old May 10th, 2004, 03:23 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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?
 
Old May 10th, 2004, 03:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I'll wait for 2.0 which I've read will have validation controls for CheckBoxLists. :)

 
Old May 10th, 2004, 03:56 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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?
 
Old May 10th, 2004, 04:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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...






Similar Threads
Thread Thread Starter Forum Replies Last Post
$@src newbieboobers XSLT 2 March 12th, 2008 04:22 PM
Beginner's trouble - location of Default.aspx laputafish BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 October 22nd, 2006 06:38 AM
Listing 18-11 <location path='AdminPage.aspx'> terry hutt BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 0 June 20th, 2006 05:35 PM
chapter2-src\src\ch02\sample5 _ need help M7777777bill BOOK: Professional Java Development with the Spring Framework 0 June 14th, 2006 10:00 PM
Change TextBox control location on aspx page minhpx General .NET 2 March 4th, 2005 08:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.