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