Here's what I've done so far:
The following markup for an asp:image is in an aspx file in my root folder:
<asp:Image runat="server" ID="imgGradLarge" ImageUrl='<%#
imageFileToDisplay("~/Images/ClassmatePics/", val("GradPhotoFileName"))
%>'></asp:Image>
This VB.net code is in my App_Code folder in a file caled MyUtils.vb
Public Shared Function imageFileToDisplay(ByVal imageFilePath As String,
ByVal imageFileName As String) As String
If System.IO.File.Exists(imageFilePath & "/" & imageFileName) Then
imageFileToDisplay = imageFilePath & "/" & imageFileName
Else
imageFileToDisplay = imageFilePath & "/NoClassmatePic.jpg"
End If
End Function
I'm sure there's more wrong that I am not aware of but for starters I get
this error:
Compiler Error Message: BC30451: Name 'imageFileToDisplay' is not declared.
If you are tempted to respond with "You need to declare
'imageFileToDisplay'" then please don't respond. I need to know HOW to do
that in the aspx markup. I haven't found anything that explains how to do
that.
If you see anything else I need to correct, please feel free to be as
specific as possible.
I really need specific coding help. I'm a bit lost on this right now. Pseudo
code suggestions are not what I'm looking for. I need someone to either show
me (I'm still learning) how to corrrect the above code or at least point me
to a website that expains (with actual example code) how to do what I'm
trying to do.
Keith
"Keith G Hicks" <kr*@comcast.netwrote in message
news:eZ**************@TK2MSFTNGP05.phx.gbl...
I'm hoping there's a simple way to do this. I need to show a dummy image
in
an asp image object if the file is missing. Here's my asp.net 2.0 markup:
<asp:Image ID="imgGrad" runat="server" BorderColor="DimGray"
BorderStyle="Solid" BorderWidth="1px" Height="120px" ImageUrl='<%#
"~/Images/ClassmatePics/" & Eval("GradPhotoFileName") %>' ToolTip="Click
to
enlarge" /></td>
"GradPhotoFileName" is stored in a field in a table. If the file name
stored
in the table is "JeffJones.jpg" but there is no "JeffJones.jpg" file in
the
"~/Images/ClassmatePics/" folder then I have a dummy jpg image that I want
to show ("MissingPhoto.jpg").
I'm hoping there's an easy way to do that maybe in the EVAL code but I
don't
know how. Can someone help me out?
Thanks,
Keith