Solved

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

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Webpage needs to float with gray border all around 7 258
Jquery submit form question 11 102
Need graphics tool to create card game 2 139
Dreamweaver server behavior gone 6 138
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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