Solved

"image not provided" Dreamweaver 2004 MX, ASP.NET VB

Posted on 2004-08-21
6
157 Views
Last Modified: 2010-04-25
In making a file upload optional, when someone decides not to upload a file, is there a way to make the display page appear without that broken gif image? Maybe with words that say, "image not provided" - something like that....

I know in .asp the code is something like this, but I can't get anything to work in ASP.NET VB.

<% if myRecordset.Fields.Item("ImageFileName").Value <> "" then %>
<IMG SRC="/upload/<%=myRecordset.Fields.Item("ImageFileName").Value%>">
<% else ' no image %>
Image Not Provided
<% end if ' image check %>
0
Comment
Question by:ajstubblefield
6 Comments
 
LVL 8

Expert Comment

by:alexhogan
ID: 11862314
What you are saying with your statement;

<% if myRecordset.Fields.Item("ImageFileName").Value <> "" then %>

is that if your "ImageFileName" field is not empty then;

<IMG SRC="/upload/<%=myRecordset.Fields.Item("ImageFileName").Value%>">

display the image named in the database field "ImageFileName".

<% else ' no image %>
Image Not Provided
<% end if ' image check %>

else display the text "Image Not Provided".  However this is checking to see that the field is not empty.

Try changing your else condition to;

<% elseif  myRecordset.Fields.Item("ImageFileName").Value = "" then ' no image %>
or
<% elseif  myRecordset.Fields.Item("ImageFileName").Value = IsNull then ' no image %>

Image Not Provided
<% end if ' image check %>

or better yet give that field a default value of "no image" or something similar, and check for that value.

<% elseif  myRecordset.Fields.Item("ImageFileName").Value = "no image" then ' no image %>

0
 

Author Comment

by:ajstubblefield
ID: 11865741
I guess that I should have been clearer, this is for a ASP.NET VB site not .asp VB.

What I am looking for is, the user has the option of adding an image or not, if they decide not to add the image I would like to get rid of the nasty little x, and replace it with some text or a blank gif.

Here is what I came up with to replace with a gif:

<img src=”<If IsNull(dsProperty("Image_01")) then response.Write("http://otherdomain.com/property/no_image.gif") else Response.Write "http://wdthost.com/property/<%# dsProperty.FieldValue("Image_01", Container) %>">
0
 
LVL 8

Expert Comment

by:alexhogan
ID: 11866524
The code above is asp.net.

The problem with your statement above is that you are checking to see if the field is not empty and not checking for other conditions.

However, I'm glad that you found something that will work for you.
0
 
LVL 3

Expert Comment

by:swarnajyothirmayi123
ID: 11968883
since you are using asp.net you can use like this

<asp:Image runat="server" id="Image"/>
<asp:label runat="server" id="ImageNotFound" text="Image Not Found"/>

Sub Page_Load()
if not isPostBack then
'query the database and get the datatable.
'check if the database value is null
'if so then say
if IsNull("Image_01") then
Image.visible=false
ImageNotFound.Visible=true
Else
ImageNotFound.visible=false
Image.visible=true
Image.ImageURL="http://otherdomain.com/property/no_image.gif"
End if
End if
End Sub

or you can use

<asp:Image runat="server" id="Image"/>

Sub Page_Load()
if not isPostBack then
'query the database and get the datatable.
'check if the database value is null
'if so then say
if IsNull("Image_01") then
Image.ImageURL ="http://otherdomain.com/property/no_image.gif"
Else
Image.ImageURL=datatable.Rows(0).Item("Image_01")
End if
End if
End Sub
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12268019
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Resume template for HTML/Dreamweaver website 9 513
Getting the co-ordinates of a map 1 171
CSS HTML Text Alignment 13 418
Adobe Products Forum? 3 147
For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now