Be the first to write a review
Pure ASP Upload 3 Review by James Threadgill
In this tutorial we will look at how to take your image handling options to the limit
DMXzone’s Pure ASP Upload is one of the best Tools I have for creating dynamic web sites. I’ve been using it over ten years. But there’s never really enough? Is there? Dreamweaver is a great tool for creating dynamic website, but if you want to get the most out of Dreamweaver and tools like DMXzone Pure ASP Upload, you have to reach under the hood and get your hands dirty by fine-tuning your code. With a little hand coding, however, there is no reason your applications cannot be as powerful and feature packed as any available.
Taking it to the Limit with Pure ASP upload 3.0: Image Update Options
DMXzone Pure ASP Upload add-on pack will allow you to delete the image on update or when you delete a record. However, there's no way to completely remove the image from an existing record once one has been uploaded. Due to the way Dreamweaver and the extension layer works, the only option is to replace it with another image. In addition to all the functionality Pure ASP Upload and Smart Image Processor offered I also wanted my CMS to have options to remove an image from the page/product/article whatever the case may be without replacing it. And with product catalogues and applications where there are child records which have images you will want to set up the deletes of the child records to prevent slowing your application with widows and orphans. And you'll want to delete images associated with child records as well.
In this tutorial we'll first look at how to delete one image and set the database field null by toggling the skip empty fields feature of Pure ASP Upload 3. Then, we will learn to delete an image and its thumb while also setting the database field to null.
If you implement the methods presented in this tutorial, not only will you offer your users more options, your applications will run faster and consume fewer resources.
This tutorial assumes you know how to create a record set to populate your form with existing data. If you have never configured a connection string, created a record set, populated a form with data, applied an insert or update behaviour and successfully run the page then this tutorial is not for you. Of course you also need to know how to apply the Pure ASP Upload behaviour. The first thing we do is set up our form. So let's get started!
Since we're dealing with images it seems a good idea to display the existing image on the update page so the user can make a decision as to whether or not to replace or remove the image. To do this we will create a conditional region. The conditional region will display two elements: If the database image field has a value other than null, the first will be image itself. The second element is the Delete Image? checkbox. The conditional region will do two things. If there is an image, it will be displayed along with the Delete Image? checkbox. If there is no image, the message No existing image will be displayed. If the record set image field has an image specified and no image is found, then the dreaded red X will appear. On the front of end of the application, I prefer to use the file scripting object to determine if the specified image exists, before displaying it, thus avoiding the red X when the image cannot be found. You will be learning to use the file scripting object into today's tutorial.
Tip: The File Scripting Object--often abbreviated fso--allows us to access the server file system.
Insert two new rows in your form. And the first cell of the first row type Existing Image. In the second row open ASP script block and type If to open the conditional region and from the bindings panel drag the record set image field onto the page after the opening If. Then enter the not equal symbol empty quote marks and the word Then. Now close to script block.
In the second cell, create an image tag to display your image. In the first cell of the second row, type Delete Image? In the second cell, insert a form checkbox, name it Delete_Image, set checked value is Y. Enter a carriage return, open an ASP script block. Type else and close the ASP script block. Type No Image Available. Open an ASP script block type End If to close the conditional region.
<td colspan="2"> </td>
<% If (rs_links.Fields.Item("Link_Image").Value)<> "" Then%>
<img src="../site_images/<%=(rs_links.Fields.Item("Link_Image").Value)%>" alt="Existing Image" /></td>
<td colspan="2">delete Image?</td>
<td><input name="Delete_Image" type="checkbox" id="Delete_Image" value="Y" />
<% Else%>No Image Available
<% End If %>
Form code block
The Delete Image? checkbox does two things if checked. It turns off the skip empty fields feature of Pure ASP Upload and it turns on the code that deletes the image file from the server. Turning off the skip empty fields feature allows us to set the record set image field back to a null value.
Page with no image. 1
Page with image 1
James Threadgill has authored numerous tutorials on ASP and ASP.NET web development, published on such sites as the Dynamic Zones and MSDN Accademic Alliance. He co-authored the Sam's book Dreamweaver MX: ASP.NET Web Development.
James first began computer programming in 1995 while attending Alvin Community College. He completed a certificate of computer science program and an Associate of Arts degree at Alvin before going on to the University of Houston-Clear Lake where he was awarded a Bachelor of Science and a Master of Arts.
James publishes fiction, poetry, and visual arts under the name Wayne James. His fiction first appeared in Raconteur in 1995 and since has been published numerous times: in Hadrosaur Tales 5 and 7, Bayousphere, and in the Write Gallery e-zine. His poetry first appeared in the small press magazine Lucidity in 1996 and has been published numerous times since. His collection of fiction and poetry, When Only the Moon Rages, was released in 2000. Most recently his work appeared in Tales of the Talisman winter 2010 and spring 2011 issues. James currently attends graduate school at the University of Houston and owns and operates small web design and internet marketing firm, WWWeb Concepts, with his wife, Karen, in Houston, TX USA.
You must me logged in to write a review.