tags:

views:

94

answers:

1

i can't display the image on my aspx view.. i'm using mysql as database

i have this code for my model:

Imports Microsoft.VisualBasic
Imports System.Data

Public Class ClassPhotosConnection
    Inherits ClassConnection

    Public Function pictureSelect() As DataTable
        Return ReadData("SELECT * FROM pictures")
    End Function
End Class

for the controller:

Public Class AdministrationController
    Inherits Global.System.Web.Mvc.Controller
     Private dPhotos As New ClassPhotosConnection

         <AcceptVerbs(HttpVerbs.Get)> _
         Function Photos() As ActionResult
             Dim _photos As DataTable = dPhotos.pictureSelect()
             Return View(_photos)
         End Function
End Class

for the view:

<div>
    <form action="<%url.action("Photos") %>">
    <%Using Html.BeginForm%>
    <%Dim _photos As datatable = ViewData.Model%>
    <%For count As Integer = 0 To _photos.Rows.Count - 1%>
    <img src='<%=_photos.Rows(count).Item("picURL") %>' alt="" />
    <p>
    <%=_photos.Rows(count).Item("picCaption")%>
    </p>
    <%Next%>
    <%End Using%>
    </form>
</div>

the only thing that is displayed is the picCaption..it seems that it cannot call src='<%=_photos.Rows(count).Item("picURL") %>' how else can i display the image?

thank you!

A: 

does the picURL contain a relative or absolute reference to the image? If the reference is realtive, you'll probably need to use the Url.Content method to map the path correctly.

<img src='<%= Url.Content("~/" + _photos.Rows(count).Item("picURL")) %>' alt="" />
lomaxx
now the image is displayed..thank you!=)
tiff
how can i put the src in the value of my input file so that by default the input type="file" will already have the value of the img src..?thank you!
tiff