Displaying images

Discussion in 'ASP .Net' started by Shelly, Sep 12, 2007.

  1. Shelly

    Shelly Guest

    I have two problems with what I am working on and would appreciate
    suggestions.

    Problem 1: The images are not displaying. I see that small box placeholder.
    Problem 2: The hyperlink is doing nothing.

    Here is the section of code for the display:
    <ItemTemplate>
    <asp:Image Id="Image1" runat="server" ImageUrl='<?#
    Container.DataItem("TheFile") %>' />
    <br>
    <asp:Hyperlink ID="Hyperlink1" runat="server" Target="_blank"
    NavigateUrl='<%# Container.DataItem("TheFile") %>'>
    <%# Container.DataItem("TheName") %></asp:Hyperlink>
    </ItemTemplate>


    In the vb code-behind, the relevent code is:
    dt = New DataTable
    dt.Columns.Add(New DataColumn("TheFile", GetType(String)))
    dt.Columns.Add(New DataColumn("TheName", GetType(String)))

    For Each File in files
    Dim name as String = getfiletitle(File)
    dr = dt.NewRow()
    dr(0) = File
    dr(1) = name
    dt.Rows.Add(dr)
    Next

    CreateDataSource = New DataView(dt)


    Now when I look in the debugger, the value for File is correct and is
    something like C:\the_full_path\the_file.jpg and the value for name is also
    correct as the_file.jpg. The value that appears on the screen for the
    hyperlink is correct and is the value of name. Putting the mouse over the
    hyperling yields something like file:///c:/the_full_path/the_file.jpg, but
    clicking it does nothing. Getting the properties of the block placeholder
    for the picture just gives a "general" tab and the value is just the name of
    the file. It doesn't display.

    Any help would be appreciated.

    --
    Shelly
     
    Shelly, Sep 12, 2007
    #1
    1. Advertising

  2. Shelly

    Shelly Guest

    A little more info on the hyperlink problem. I added a third item to the
    ItemTemplate. It is

    <br /><a href="C:/the_complete_file_path/JonFamily.jpg">Jon Family</a>

    Of course, it shows up as the third thing for each and is the same for all
    three image files that are in my directory. When I click on it, nothing
    happens. When I cut and paste that specification into the browser address
    line, the file displays.

    -- Is there some setting in the DataList that needs changing?
    -- Should I be using other than ItemTemplate?
    -- What about the display problem I am still having?

    I am blocked and need some help.

    Shelly

    "Shelly" <> wrote in message
    news:...
    >I have two problems with what I am working on and would appreciate
    >suggestions.
    >
    > Problem 1: The images are not displaying. I see that small box
    > placeholder.
    > Problem 2: The hyperlink is doing nothing.
    >
    > Here is the section of code for the display:
    > <ItemTemplate>
    > <asp:Image Id="Image1" runat="server" ImageUrl='<?#
    > Container.DataItem("TheFile") %>' />
    > <br>
    > <asp:Hyperlink ID="Hyperlink1" runat="server" Target="_blank"
    > NavigateUrl='<%# Container.DataItem("TheFile") %>'>
    > <%# Container.DataItem("TheName") %></asp:Hyperlink>
    > </ItemTemplate>
    >
    >
    > In the vb code-behind, the relevent code is:
    > dt = New DataTable
    > dt.Columns.Add(New DataColumn("TheFile", GetType(String)))
    > dt.Columns.Add(New DataColumn("TheName", GetType(String)))
    >
    > For Each File in files
    > Dim name as String = getfiletitle(File)
    > dr = dt.NewRow()
    > dr(0) = File
    > dr(1) = name
    > dt.Rows.Add(dr)
    > Next
    >
    > CreateDataSource = New DataView(dt)
    >
    >
    > Now when I look in the debugger, the value for File is correct and is
    > something like C:\the_full_path\the_file.jpg and the value for name is
    > also correct as the_file.jpg. The value that appears on the screen for
    > the hyperlink is correct and is the value of name. Putting the mouse over
    > the hyperling yields something like file:///c:/the_full_path/the_file.jpg,
    > but clicking it does nothing. Getting the properties of the block
    > placeholder for the picture just gives a "general" tab and the value is
    > just the name of the file. It doesn't display.
    >
    > Any help would be appreciated.
    >
    > --
    > Shelly
    >
    >
     
    Shelly, Sep 12, 2007
    #2
    1. Advertising

  3. Shelly

    Shelly Guest

    More weirdness!
    Just to see what would happen, I put <img id="foo"
    src="C:\the_full_path\JonFamily.jpg" />. It didn't display either, and this
    was right below my Content statement. If I cut and paste that URL, it
    displays.

    Suggestions? Whatever it is, it will probably solve both problems when I
    find out.

    Shelly


    "Shelly" <> wrote in message
    news:...
    >A little more info on the hyperlink problem. I added a third item to the
    >ItemTemplate. It is
    >
    > <br /><a href="C:/the_complete_file_path/JonFamily.jpg">Jon Family</a>
    >
    > Of course, it shows up as the third thing for each and is the same for all
    > three image files that are in my directory. When I click on it, nothing
    > happens. When I cut and paste that specification into the browser address
    > line, the file displays.
    >
    > -- Is there some setting in the DataList that needs changing?
    > -- Should I be using other than ItemTemplate?
    > -- What about the display problem I am still having?
    >
    > I am blocked and need some help.
    >
    > Shelly
    >
    > "Shelly" <> wrote in message
    > news:...
    >>I have two problems with what I am working on and would appreciate
    >>suggestions.
    >>
    >> Problem 1: The images are not displaying. I see that small box
    >> placeholder.
    >> Problem 2: The hyperlink is doing nothing.
    >>
    >> Here is the section of code for the display:
    >> <ItemTemplate>
    >> <asp:Image Id="Image1" runat="server" ImageUrl='<?#
    >> Container.DataItem("TheFile") %>' />
    >> <br>
    >> <asp:Hyperlink ID="Hyperlink1" runat="server" Target="_blank"
    >> NavigateUrl='<%# Container.DataItem("TheFile") %>'>
    >> <%# Container.DataItem("TheName") %></asp:Hyperlink>
    >> </ItemTemplate>
    >>
    >>
    >> In the vb code-behind, the relevent code is:
    >> dt = New DataTable
    >> dt.Columns.Add(New DataColumn("TheFile", GetType(String)))
    >> dt.Columns.Add(New DataColumn("TheName", GetType(String)))
    >>
    >> For Each File in files
    >> Dim name as String = getfiletitle(File)
    >> dr = dt.NewRow()
    >> dr(0) = File
    >> dr(1) = name
    >> dt.Rows.Add(dr)
    >> Next
    >>
    >> CreateDataSource = New DataView(dt)
    >>
    >>
    >> Now when I look in the debugger, the value for File is correct and is
    >> something like C:\the_full_path\the_file.jpg and the value for name is
    >> also correct as the_file.jpg. The value that appears on the screen for
    >> the hyperlink is correct and is the value of name. Putting the mouse
    >> over the hyperling yields something like
    >> file:///c:/the_full_path/the_file.jpg, but clicking it does nothing.
    >> Getting the properties of the block placeholder for the picture just
    >> gives a "general" tab and the value is just the name of the file. It
    >> doesn't display.
    >>
    >> Any help would be appreciated.
    >>
    >> --
    >> Shelly
    >>
    >>

    >
    >
     
    Shelly, Sep 12, 2007
    #3
  4. The image path should not be absolute. Try relative path or full path e.g.
    http://server/appname/images/imagename.jpg
    Secondly the data bound expression seems little strange
    <?# Container.DataItem("TheFile") %>

    shouldn't this be like
    <%# Container.DataItem("TheFile") %>

    - Harshal

    "Shelly" <> wrote in message
    news:...
    >I have two problems with what I am working on and would appreciate
    >suggestions.
    >
    > Problem 1: The images are not displaying. I see that small box
    > placeholder.
    > Problem 2: The hyperlink is doing nothing.
    >
    > Here is the section of code for the display:
    > <ItemTemplate>
    > <asp:Image Id="Image1" runat="server" ImageUrl='<?#
    > Container.DataItem("TheFile") %>' />
    > <br>
    > <asp:Hyperlink ID="Hyperlink1" runat="server" Target="_blank"
    > NavigateUrl='<%# Container.DataItem("TheFile") %>'>
    > <%# Container.DataItem("TheName") %></asp:Hyperlink>
    > </ItemTemplate>
    >
    >
    > In the vb code-behind, the relevent code is:
    > dt = New DataTable
    > dt.Columns.Add(New DataColumn("TheFile", GetType(String)))
    > dt.Columns.Add(New DataColumn("TheName", GetType(String)))
    >
    > For Each File in files
    > Dim name as String = getfiletitle(File)
    > dr = dt.NewRow()
    > dr(0) = File
    > dr(1) = name
    > dt.Rows.Add(dr)
    > Next
    >
    > CreateDataSource = New DataView(dt)
    >
    >
    > Now when I look in the debugger, the value for File is correct and is
    > something like C:\the_full_path\the_file.jpg and the value for name is
    > also correct as the_file.jpg. The value that appears on the screen for
    > the hyperlink is correct and is the value of name. Putting the mouse over
    > the hyperling yields something like file:///c:/the_full_path/the_file.jpg,
    > but clicking it does nothing. Getting the properties of the block
    > placeholder for the picture just gives a "general" tab and the value is
    > just the name of the file. It doesn't display.
    >
    > Any help would be appreciated.
    >
    > --
    > Shelly
    >
    >
     
    Harshal Pachpande, Sep 12, 2007
    #4
  5. Shelly

    Shelly Guest

    "Harshal Pachpande" <> wrote in message
    news:...
    > The image path should not be absolute. Try relative path or full path e.g.
    > http://server/appname/images/imagename.jpg
    > Secondly the data bound expression seems little strange
    > <?# Container.DataItem("TheFile") %>


    It made no difference

    >
    > shouldn't this be like
    > <%# Container.DataItem("TheFile") %>


    typo. It was as you have it.


    >
    > - Harshal
    >
    > "Shelly" <> wrote in message
    > news:...
    >>I have two problems with what I am working on and would appreciate
    >>suggestions.
    >>
    >> Problem 1: The images are not displaying. I see that small box
    >> placeholder.
    >> Problem 2: The hyperlink is doing nothing.
    >>
    >> Here is the section of code for the display:
    >> <ItemTemplate>
    >> <asp:Image Id="Image1" runat="server" ImageUrl='<?#
    >> Container.DataItem("TheFile") %>' />
    >> <br>
    >> <asp:Hyperlink ID="Hyperlink1" runat="server" Target="_blank"
    >> NavigateUrl='<%# Container.DataItem("TheFile") %>'>
    >> <%# Container.DataItem("TheName") %></asp:Hyperlink>
    >> </ItemTemplate>
    >>
    >>
    >> In the vb code-behind, the relevent code is:
    >> dt = New DataTable
    >> dt.Columns.Add(New DataColumn("TheFile", GetType(String)))
    >> dt.Columns.Add(New DataColumn("TheName", GetType(String)))
    >>
    >> For Each File in files
    >> Dim name as String = getfiletitle(File)
    >> dr = dt.NewRow()
    >> dr(0) = File
    >> dr(1) = name
    >> dt.Rows.Add(dr)
    >> Next
    >>
    >> CreateDataSource = New DataView(dt)
    >>
    >>
    >> Now when I look in the debugger, the value for File is correct and is
    >> something like C:\the_full_path\the_file.jpg and the value for name is
    >> also correct as the_file.jpg. The value that appears on the screen for
    >> the hyperlink is correct and is the value of name. Putting the mouse
    >> over the hyperling yields something like
    >> file:///c:/the_full_path/the_file.jpg, but clicking it does nothing.
    >> Getting the properties of the block placeholder for the picture just
    >> gives a "general" tab and the value is just the name of the file. It
    >> doesn't display.
    >>
    >> Any help would be appreciated.
    >>
    >> --
    >> Shelly
    >>
    >>

    >
     
    Shelly, Sep 13, 2007
    #5
  6. Shelly

    Shelly Guest

    I take that back! The relative path did the trick. Thank you very much.
    The absolute path may also work, but it didn't for me here as I had to use
    file://___stuff___. (I am using a localhost server).

    Shelly

    "Shelly" <> wrote in message
    news:...
    >
    > "Harshal Pachpande" <> wrote in message
    > news:...
    >> The image path should not be absolute. Try relative path or full path
    >> e.g. http://server/appname/images/imagename.jpg
    >> Secondly the data bound expression seems little strange
    >> <?# Container.DataItem("TheFile") %>

    >
    > It made no difference
    >
    >>
    >> shouldn't this be like
    >> <%# Container.DataItem("TheFile") %>

    >
    > typo. It was as you have it.
    >
    >
    >>
    >> - Harshal
    >>
    >> "Shelly" <> wrote in message
    >> news:...
    >>>I have two problems with what I am working on and would appreciate
    >>>suggestions.
    >>>
    >>> Problem 1: The images are not displaying. I see that small box
    >>> placeholder.
    >>> Problem 2: The hyperlink is doing nothing.
    >>>
    >>> Here is the section of code for the display:
    >>> <ItemTemplate>
    >>> <asp:Image Id="Image1" runat="server" ImageUrl='<?#
    >>> Container.DataItem("TheFile") %>' />
    >>> <br>
    >>> <asp:Hyperlink ID="Hyperlink1" runat="server" Target="_blank"
    >>> NavigateUrl='<%# Container.DataItem("TheFile") %>'>
    >>> <%# Container.DataItem("TheName") %></asp:Hyperlink>
    >>> </ItemTemplate>
    >>>
    >>>
    >>> In the vb code-behind, the relevent code is:
    >>> dt = New DataTable
    >>> dt.Columns.Add(New DataColumn("TheFile", GetType(String)))
    >>> dt.Columns.Add(New DataColumn("TheName", GetType(String)))
    >>>
    >>> For Each File in files
    >>> Dim name as String = getfiletitle(File)
    >>> dr = dt.NewRow()
    >>> dr(0) = File
    >>> dr(1) = name
    >>> dt.Rows.Add(dr)
    >>> Next
    >>>
    >>> CreateDataSource = New DataView(dt)
    >>>
    >>>
    >>> Now when I look in the debugger, the value for File is correct and is
    >>> something like C:\the_full_path\the_file.jpg and the value for name is
    >>> also correct as the_file.jpg. The value that appears on the screen for
    >>> the hyperlink is correct and is the value of name. Putting the mouse
    >>> over the hyperling yields something like
    >>> file:///c:/the_full_path/the_file.jpg, but clicking it does nothing.
    >>> Getting the properties of the block placeholder for the picture just
    >>> gives a "general" tab and the value is just the name of the file. It
    >>> doesn't display.
    >>>
    >>> Any help would be appreciated.
    >>>
    >>> --
    >>> Shelly
    >>>
    >>>

    >>

    >
    >
     
    Shelly, Sep 13, 2007
    #6
  7. Shelly

    Mick Walker Guest

    Shelly wrote:
    > I take that back! The relative path did the trick. Thank you very much.
    > The absolute path may also work, but it didn't for me here as I had to use
    > file://___stuff___. (I am using a localhost server).
    >
    > Shelly
    >
    > "Shelly" <> wrote in message
    > news:...
    >> "Harshal Pachpande" <> wrote in message
    >> news:...
    >>> The image path should not be absolute. Try relative path or full path
    >>> e.g. http://server/appname/images/imagename.jpg
    >>> Secondly the data bound expression seems little strange
    >>> <?# Container.DataItem("TheFile") %>

    >> It made no difference
    >>
    >>> shouldn't this be like
    >>> <%# Container.DataItem("TheFile") %>

    >> typo. It was as you have it.
    >>
    >>
    >>> - Harshal
    >>>
    >>> "Shelly" <> wrote in message
    >>> news:...
    >>>> I have two problems with what I am working on and would appreciate
    >>>> suggestions.
    >>>>
    >>>> Problem 1: The images are not displaying. I see that small box
    >>>> placeholder.
    >>>> Problem 2: The hyperlink is doing nothing.
    >>>>
    >>>> Here is the section of code for the display:
    >>>> <ItemTemplate>
    >>>> <asp:Image Id="Image1" runat="server" ImageUrl='<?#
    >>>> Container.DataItem("TheFile") %>' />
    >>>> <br>
    >>>> <asp:Hyperlink ID="Hyperlink1" runat="server" Target="_blank"
    >>>> NavigateUrl='<%# Container.DataItem("TheFile") %>'>
    >>>> <%# Container.DataItem("TheName") %></asp:Hyperlink>
    >>>> </ItemTemplate>
    >>>>
    >>>>
    >>>> In the vb code-behind, the relevent code is:
    >>>> dt = New DataTable
    >>>> dt.Columns.Add(New DataColumn("TheFile", GetType(String)))
    >>>> dt.Columns.Add(New DataColumn("TheName", GetType(String)))
    >>>>
    >>>> For Each File in files
    >>>> Dim name as String = getfiletitle(File)
    >>>> dr = dt.NewRow()
    >>>> dr(0) = File
    >>>> dr(1) = name
    >>>> dt.Rows.Add(dr)
    >>>> Next
    >>>>
    >>>> CreateDataSource = New DataView(dt)
    >>>>
    >>>>
    >>>> Now when I look in the debugger, the value for File is correct and is
    >>>> something like C:\the_full_path\the_file.jpg and the value for name is
    >>>> also correct as the_file.jpg. The value that appears on the screen for
    >>>> the hyperlink is correct and is the value of name. Putting the mouse
    >>>> over the hyperling yields something like
    >>>> file:///c:/the_full_path/the_file.jpg, but clicking it does nothing.
    >>>> Getting the properties of the block placeholder for the picture just
    >>>> gives a "general" tab and the value is just the name of the file. It
    >>>> doesn't display.
    >>>>
    >>>> Any help would be appreciated.
    >>>>
    >>>> --
    >>>> Shelly
    >>>>
    >>>>

    >>

    >
    >

    Look into Server.MapPath()
     
    Mick Walker, Sep 13, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David J. Berman
    Replies:
    0
    Views:
    1,425
    David J. Berman
    Jun 24, 2003
  2. Matt
    Replies:
    0
    Views:
    391
  3. Vinay

    Displaying Images ?

    Vinay, Oct 24, 2003, in forum: ASP .Net
    Replies:
    7
    Views:
    534
    vMike
    Oct 25, 2003
  4. =?Utf-8?B?SmltIE1hY2U=?=

    Displaying images from a database in an image control

    =?Utf-8?B?SmltIE1hY2U=?=, May 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    393
    Ashish M Bhonkiya
    May 5, 2004
  5. Ken Varn
    Replies:
    2
    Views:
    578
    Ken Varn
    May 11, 2004
Loading...

Share This Page