Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 January 21st, 2004, 11:44 AM
Authorized User
 
Join Date: Jan 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default Image Data

I have a products table and I want to create a button that points to some images jpg. for each product. I dont want to store the images in SQL Server, I want to use a file system. I do I call these images through code in ASP?

 
Old January 21st, 2004, 11:52 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You should store the image name in the database. Then just write out an image tag to the HTML with the value from the database as the "src" attribute value.

Remember that you don't want to store the literal path to the local file, because the browser can only see relative paths related to the application URL. So if you store your images in c:\inetpub\wwwroot\myWebApp\images and the ASP page is c:\inetpub\wwwroot\myWebApp\products.asp then the image tag should end up looking like this: <img src="images/<image filename from database>">.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old January 21st, 2004, 12:20 PM
Authorized User
 
Join Date: Jan 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot this is just what I was looking for. One more question, can you send me some code on how I would call this from a button.

 
Old January 21st, 2004, 12:51 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Well... I'm not sure what you mean by "call from a button". This is something you do on the page.

You said in the first post "I want to create a button that points to some images", but this in itself doesn't really make sense. What do you want this button to do? Open a new window with the image in it?

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old January 21st, 2004, 01:06 PM
Authorized User
 
Join Date: Jan 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for the confusion planoie. Yes, I have an ASP page that list all the products. I have a column that will store the jpg file name like you described, I want to create a button that will pop up another window with the corresponding image jpg.

 
Old January 21st, 2004, 03:16 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

For a new window, you can use javascript on the button click handler:

<input type="button" onClick="window.open(...);">

In window.open() you provide a window name, the destination URL and an optional list of options that set the various window properties of the new browser window.

The URL for the new window can simply be the URL to the image. You don't even need a page to show it in, just the image itself.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old January 21st, 2004, 03:38 PM
Authorized User
 
Join Date: Jan 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks dude!
You know Im an ASP Novie. I'm originally a DBA here, but I'm learning new things like ASP programming.

in the windows.open how do I insert a variable (URL) can it be the field name in my database where I store the jpg names? You also said I shouldnt store the url name in the column just the name of the file, will this change now? Lets say my column name is "images" should I pass this into windows.open() using a variable?

<input type="button" onClick="window.open(...);">

 
Old January 21st, 2004, 04:40 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You button HTML should end up looking like this...


<input type="button" onClick="window.open('imageView','images/<%=imageFileNameFromDB%>');">

You don't need to change what you are storing, still just store the image name.
 
Old January 21st, 2004, 06:08 PM
Authorized User
 
Join Date: Jan 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is what I'm using and it gives me an error "Not Valid"


<input type="button" value="Image" class="boton120" name="Image" language="javascript" id="Image" onClick="window.open('imageView','LPimages/<%=rsLPMae.Fields("Ps_ImageUrl")%>');">

I even hardcoded the complete path to the file /LPImages/BeerSaloon1.jpg and it still gave me the same error.

 
Old January 21st, 2004, 06:28 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What do you actually get for the URL in the new window?

Is "Not valid" a code error or a browser error?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems in Image Data Type ayan.mukherjee VB Databases Basics 0 June 30th, 2008 03:54 AM
Javascript and binary image data thenoseknows ASP.NET 2.0 Professional 0 January 8th, 2007 07:26 PM
base64_encode() to encode image data vibinkrish Beginning PHP 1 March 9th, 2006 11:27 AM
IMAGE Data type ranakdinesh BOOK: Professional C#, 2nd and 3rd Editions 6 March 18th, 2005 08:35 AM
Image in a data access page. Brownr Access 7 March 2nd, 2004 12:17 AM





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