Solved

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

Posted on 2004-08-21
6
156 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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 article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

21 Experts available now in Live!

Get 1:1 Help Now