substitute img when EVAL file name is not found

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Keith G Hicks

    substitute img when EVAL file name is not found

    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="Di mGray"
    BorderStyle="So lid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
    "~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>' ToolTip="Click to
    enlarge" /></td>


    "GradPhotoFileN ame" 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


  • Peter Bromberg [C# MVP]

    #2
    Re: substitute img when EVAL file name is not found

    Probably the easiest way is to call a protected method that accepts type
    object (e.g., Eval("GradPhoto FileName") ) -- and returns the proper string
    url to the image, or the alternate image url.
    --Peter
    "Keith G Hicks" <krh@comcast.ne twrote in message
    news:eZP7AtxqIH A.1228@TK2MSFTN GP05.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="Di mGray"
    BorderStyle="So lid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
    "~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>' ToolTip="Click
    to
    enlarge" /></td>
    >
    >
    "GradPhotoFileN ame" 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
    >
    >

    Comment

    • Keith G Hicks

      #3
      Re: substitute img when EVAL file name is not found

      I appreciate the hint but being pretty new to all of this (asp.net) I have
      no idea how to go about doing that. I'm fine with VB and can create subs and
      functions just fine so if that's what you mean I can do that part I guess
      but implementing it in my markup below is not remotely clear to me. I need
      as much help as possible.

      THanks,

      Keith

      "Peter Bromberg [C# MVP]" <pbromberg@nosp ammaam.yahoo.co mwrote in message
      news:30141463-D7AF-4A95-B050-0DD3C154A8F9@mi crosoft.com...
      Probably the easiest way is to call a protected method that accepts type
      object (e.g., Eval("GradPhoto FileName") ) -- and returns the proper
      string
      url to the image, or the alternate image url.
      --Peter
      "Keith G Hicks" <krh@comcast.ne twrote in message
      news:eZP7AtxqIH A.1228@TK2MSFTN GP05.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="Di mGray"
      BorderStyle="So lid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
      "~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>' ToolTip="Click
      to
      enlarge" /></td>


      "GradPhotoFileN ame" 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
      >

      Comment

      • S.M. Altaf [MVP]

        #4
        Re: substitute img when EVAL file name is not found

        Do this from the codebehind. You have the value of "GradPhotoFileN ame", you
        can check if System.Io.File. Exists() and if it doesn't, set the .ImageUrl
        property of your imgGrad image to your dummy image URL. I do not know how
        you're binding your image to the data though, but how you assign the values
        in the codebehind will depend on the method you're using.

        --
        ---------------------------------------------------
        S.M. Altaf [MVP]



        "Keith G Hicks" <krh@comcast.ne twrote in message
        news:#maMeNyqIH A.3420@TK2MSFTN GP04.phx.gbl...
        I appreciate the hint but being pretty new to all of this (asp.net) I have
        no idea how to go about doing that. I'm fine with VB and can create subs
        and
        functions just fine so if that's what you mean I can do that part I guess
        but implementing it in my markup below is not remotely clear to me. I need
        as much help as possible.
        >
        THanks,
        >
        Keith
        >
        "Peter Bromberg [C# MVP]" <pbromberg@nosp ammaam.yahoo.co mwrote in
        message
        news:30141463-D7AF-4A95-B050-0DD3C154A8F9@mi crosoft.com...
        >Probably the easiest way is to call a protected method that accepts type
        >object (e.g., Eval("GradPhoto FileName") ) -- and returns the proper
        string
        >url to the image, or the alternate image url.
        >--Peter
        >"Keith G Hicks" <krh@comcast.ne twrote in message
        >news:eZP7AtxqI HA.1228@TK2MSFT NGP05.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="Di mGray"
        BorderStyle="So lid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
        "~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>'
        ToolTip="Click
        to
        enlarge" /></td>
        >
        >
        "GradPhotoFileN ame" 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
        >
        >
        >>
        >
        >

        Comment

        • Keith G Hicks

          #5
          Re: substitute img when EVAL file name is not found

          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="imgGradLarg e" ImageUrl='<%#
          imageFileToDisp lay("~/Images/ClassmatePics/", val("GradPhotoF ileName"))
          %>'></asp:Image>

          This VB.net code is in my App_Code folder in a file caled MyUtils.vb

          Public Shared Function imageFileToDisp lay(ByVal imageFilePath As String,
          ByVal imageFileName As String) As String
          If System.IO.File. Exists(imageFil ePath & "/" & imageFileName) Then
          imageFileToDisp lay = imageFilePath & "/" & imageFileName
          Else
          imageFileToDisp lay = 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 'imageFileToDis play' is not declared.

          If you are tempted to respond with "You need to declare
          'imageFileToDis play'" 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" <krh@comcast.ne twrote in message
          news:eZP7AtxqIH A.1228@TK2MSFTN GP05.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="Di mGray"
          BorderStyle="So lid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
          "~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>' ToolTip="Click
          to
          enlarge" /></td>
          >
          >
          "GradPhotoFileN ame" 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
          >
          >

          Comment

          • Keith G Hicks

            #6
            Re: substitute img when EVAL file name is not found

            Ok, I moved my function into the codebehind file for the page as follows:

            Protected Function imageFileToDisp lay(ByVal imageFilePath As String,
            ByVal imageFileName As String) As String
            If File.Exists(Res olveUrl(imageFi lePath) & imageFileName) Then
            imageFileToDisp lay = imageFilePath & imageFileName
            Else
            imageFileToDisp lay = imageFilePath & "NoClassmatePic .jpg"
            End If
            End Function

            and it runs without errors. The problem is that the
            ResolveUrl(imag eFilePath) only returns part of the path like this:

            /mysite/...

            but I need

            C:\Inetpub\wwwr oot\mysite\.... ..

            What vb.net function will give me this?

            Keith


            "Keith G Hicks" <krh@comcast.ne twrote in message
            news:eI3NFe4qIH A.672@TK2MSFTNG P02.phx.gbl...
            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="imgGradLarg e" ImageUrl='<%#
            imageFileToDisp lay("~/Images/ClassmatePics/", val("GradPhotoF ileName"))
            %>'></asp:Image>
            >
            This VB.net code is in my App_Code folder in a file caled MyUtils.vb
            >
            Public Shared Function imageFileToDisp lay(ByVal imageFilePath As String,
            ByVal imageFileName As String) As String
            If System.IO.File. Exists(imageFil ePath & "/" & imageFileName) Then
            imageFileToDisp lay = imageFilePath & "/" & imageFileName
            Else
            imageFileToDisp lay = 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 'imageFileToDis play' is not
            declared.
            >
            If you are tempted to respond with "You need to declare
            'imageFileToDis play'" 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" <krh@comcast.ne twrote in message
            news:eZP7AtxqIH A.1228@TK2MSFTN GP05.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="Di mGray"
            BorderStyle="So lid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
            "~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>' ToolTip="Click
            to
            enlarge" /></td>


            "GradPhotoFileN ame" 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
            >
            >

            Comment

            • David

              #7
              Re: substitute img when EVAL file name is not found

              Hhhmmmm....

              Not sure, but if your markup is calling imageFileToDisp lay, then you should
              be able to change both of the imageFileToDisp lay in your IF and ELSE
              statements to return... i.e.

              return imageFilePath & "/NoClassmatePic. jpg"


              --
              Best regards,
              Dave Colliver.

              ~~
              http://www.FOCUSPortals.com - Local franchises available


              "Keith G Hicks" <krh@comcast.ne twrote in message
              news:eI3NFe4qIH A.672@TK2MSFTNG P02.phx.gbl...
              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="imgGradLarg e" ImageUrl='<%#
              imageFileToDisp lay("~/Images/ClassmatePics/", val("GradPhotoF ileName"))
              %>'></asp:Image>
              >
              This VB.net code is in my App_Code folder in a file caled MyUtils.vb
              >
              Public Shared Function imageFileToDisp lay(ByVal imageFilePath As String,
              ByVal imageFileName As String) As String
              If System.IO.File. Exists(imageFil ePath & "/" & imageFileName) Then
              imageFileToDisp lay = imageFilePath & "/" & imageFileName
              Else
              imageFileToDisp lay = 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 'imageFileToDis play' is not
              declared.
              >
              If you are tempted to respond with "You need to declare
              'imageFileToDis play'" 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" <krh@comcast.ne twrote in message
              news:eZP7AtxqIH A.1228@TK2MSFTN GP05.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="Di mGray"
              >BorderStyle="S olid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
              >"~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>' ToolTip="Click
              to
              >enlarge" /></td>
              >>
              >>
              >"GradPhotoFile Name" 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
              >>
              >>
              >
              >

              Comment

              • David

                #8
                Re: substitute img when EVAL file name is not found

                I have never used resolveurl, so not sure what it does. However, you should
                probably look at Server.MapPath instead of resolveurl.


                --
                Best regards,
                Dave Colliver.

                ~~
                http://www.FOCUSPortals.com - Local franchises available


                "Keith G Hicks" <krh@comcast.ne twrote in message
                news:erfrou4qIH A.5068@TK2MSFTN GP02.phx.gbl...
                Ok, I moved my function into the codebehind file for the page as follows:
                >
                Protected Function imageFileToDisp lay(ByVal imageFilePath As String,
                ByVal imageFileName As String) As String
                If File.Exists(Res olveUrl(imageFi lePath) & imageFileName) Then
                imageFileToDisp lay = imageFilePath & imageFileName
                Else
                imageFileToDisp lay = imageFilePath & "NoClassmatePic .jpg"
                End If
                End Function
                >
                and it runs without errors. The problem is that the
                ResolveUrl(imag eFilePath) only returns part of the path like this:
                >
                /mysite/...
                >
                but I need
                >
                C:\Inetpub\wwwr oot\mysite\.... ..
                >
                What vb.net function will give me this?
                >
                Keith
                >
                >
                "Keith G Hicks" <krh@comcast.ne twrote in message
                news:eI3NFe4qIH A.672@TK2MSFTNG P02.phx.gbl...
                >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="imgGradLarg e" ImageUrl='<%#
                >imageFileToDis play("~/Images/ClassmatePics/", val("GradPhotoF ileName"))
                >%>'></asp:Image>
                >>
                >This VB.net code is in my App_Code folder in a file caled MyUtils.vb
                >>
                >Public Shared Function imageFileToDisp lay(ByVal imageFilePath As String,
                >ByVal imageFileName As String) As String
                > If System.IO.File. Exists(imageFil ePath & "/" & imageFileName) Then
                > imageFileToDisp lay = imageFilePath & "/" & imageFileName
                > Else
                > imageFileToDisp lay = 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 'imageFileToDis play' is not
                declared.
                >>
                >If you are tempted to respond with "You need to declare
                >'imageFileToDi splay'" 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" <krh@comcast.ne twrote in message
                >news:eZP7AtxqI HA.1228@TK2MSFT NGP05.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="Di mGray"
                BorderStyle="So lid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
                "~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>'
                ToolTip="Click
                >to
                enlarge" /></td>
                >
                >
                "GradPhotoFileN ame" 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
                >
                >
                >>
                >>
                >
                >

                Comment

                • Keith G Hicks

                  #9
                  Re: substitute img when EVAL file name is not found

                  Well I got it working. So for anyone who ever has a similar question here's
                  what I ended up doing:

                  My code behind function is as follows (with Imports System.IO at the top of
                  the file):

                  Protected Function imageFileToDisp lay(ByVal imageFileName As String) As
                  String
                  If File.Exists(Sys tem.AppDomain.C urrentDomain.Ba seDirectory &
                  "Images\Classma tePics\" & imageFileName) Then
                  imageFileToDisp lay = "~/Images/ClassmatePics/" & imageFileName
                  Else
                  imageFileToDisp lay = "~/Images/ClassmatePics/NoClassmatePic. jpg"
                  End If
                  End Function

                  System.AppDomai n.CurrentDomain .BaseDirectory is getting the entire path of
                  the site's root (C:\Inetpub\www root\mySite for example). I suppose I could
                  have passed the path from the aspx file to the code behind but it's 6 of
                  one, 1/2 dozen of the other IMO. I didn't use ResolveURL because that
                  doesn't give the the whole base path.

                  My markup in the aspx page is as follows:

                  <asp:Image ID="imgGrad" runat="server" BorderColor="Da rkGray"
                  BorderStyle="So lid" BorderWidth="1p x" Height="130px" ImageUrl='<%#
                  imageFileToDisp lay(Eval("GradP hotoFileName")) %>' ToolTip="Click to enlarge"
                  />

                  it all works perfectly fine.

                  Keith


                  Comment

                  • Peter Bromberg [C# MVP]

                    #10
                    Re: substitute img when EVAL file name is not found

                    Probably Server.MapPath( "relativepathto image") would do the trick for you.
                    Peter

                    "Keith G Hicks" <krh@comcast.ne twrote in message
                    news:eQdnK45qIH A.4884@TK2MSFTN GP06.phx.gbl...
                    Well I got it working. So for anyone who ever has a similar question
                    here's
                    what I ended up doing:
                    >
                    My code behind function is as follows (with Imports System.IO at the top
                    of
                    the file):
                    >
                    Protected Function imageFileToDisp lay(ByVal imageFileName As String) As
                    String
                    If File.Exists(Sys tem.AppDomain.C urrentDomain.Ba seDirectory &
                    "Images\Classma tePics\" & imageFileName) Then
                    imageFileToDisp lay = "~/Images/ClassmatePics/" & imageFileName
                    Else
                    imageFileToDisp lay =
                    "~/Images/ClassmatePics/NoClassmatePic. jpg"
                    End If
                    End Function
                    >
                    System.AppDomai n.CurrentDomain .BaseDirectory is getting the entire path of
                    the site's root (C:\Inetpub\www root\mySite for example). I suppose I could
                    have passed the path from the aspx file to the code behind but it's 6 of
                    one, 1/2 dozen of the other IMO. I didn't use ResolveURL because that
                    doesn't give the the whole base path.
                    >
                    My markup in the aspx page is as follows:
                    >
                    <asp:Image ID="imgGrad" runat="server" BorderColor="Da rkGray"
                    BorderStyle="So lid" BorderWidth="1p x" Height="130px" ImageUrl='<%#
                    imageFileToDisp lay(Eval("GradP hotoFileName")) %>' ToolTip="Click to
                    enlarge"
                    />
                    >
                    it all works perfectly fine.
                    >
                    Keith
                    >
                    >

                    Comment

                    • Fernando Rodriguez, MCP

                      #11
                      Re: substitute img when EVAL file name is not found

                      Actually the easiest and most efficient way is to do it with javascript on
                      the client side, just do this on your Page_Load routine:

                      imgGrad.Attribu tes("onerror") = "this.src='<dum my image relative path>;'"

                      That will cause the user's browser to load the dummy image if it doesn't
                      find the original.

                      Hope that helps,
                      Fernando Rodriguez, MCP




                      "S.M. Altaf [MVP]" <smaltaf@omgplz dntspammekthxba imsn.comwrote in message
                      news:3F211D0B-3873-4089-A2DA-906E730AF363@mi crosoft.com...
                      Do this from the codebehind. You have the value of "GradPhotoFileN ame",
                      you can check if System.Io.File. Exists() and if it doesn't, set the
                      .ImageUrl property of your imgGrad image to your dummy image URL. I do
                      not know how you're binding your image to the data though, but how you
                      assign the values in the codebehind will depend on the method you're
                      using.
                      >
                      --
                      ---------------------------------------------------
                      S.M. Altaf [MVP]

                      >
                      >
                      "Keith G Hicks" <krh@comcast.ne twrote in message
                      news:#maMeNyqIH A.3420@TK2MSFTN GP04.phx.gbl...
                      >I appreciate the hint but being pretty new to all of this (asp.net) I
                      >have
                      >no idea how to go about doing that. I'm fine with VB and can create subs
                      >and
                      >functions just fine so if that's what you mean I can do that part I guess
                      >but implementing it in my markup below is not remotely clear to me. I
                      >need
                      >as much help as possible.
                      >>
                      >THanks,
                      >>
                      >Keith
                      >>
                      >"Peter Bromberg [C# MVP]" <pbromberg@nosp ammaam.yahoo.co mwrote in
                      >message
                      >news:3014146 3-D7AF-4A95-B050-0DD3C154A8F9@mi crosoft.com...
                      >>Probably the easiest way is to call a protected method that accepts type
                      >>object (e.g., Eval("GradPhoto FileName") ) -- and returns the proper
                      >string
                      >>url to the image, or the alternate image url.
                      >>--Peter
                      >>"Keith G Hicks" <krh@comcast.ne twrote in message
                      >>news:eZP7Atxq IHA.1228@TK2MSF TNGP05.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="Di mGray"
                      >BorderStyle="S olid" BorderWidth="1p x" Height="120px" ImageUrl='<%#
                      >"~/Images/ClassmatePics/" & Eval("GradPhoto FileName") %>'
                      >ToolTip="Cli ck
                      >to
                      >enlarge" /></td>
                      >>
                      >>
                      >"GradPhotoFile Name" 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
                      >>
                      >>
                      >>>
                      >>
                      >>

                      Comment

                      Working...