Href and <%# DataBinder.Eval(Container.DataItem, "Name") %> ?

  • Thread starter Thread starter Lauchlan M
  • Start date Start date
L

Lauchlan M

Hi

In my aspx page HTML I have

<a href='<%# DataBinder.Eval(Container.DataItem, "Name") %>'> <%#
DataBinder.Eval(Container.DataItem, "Name") %>

I am trying to create a hyperlink to
applicationroot\FileUploads\Filename.FileExtension.

At the moment it instead generates

http://localhost/MyWebApplication/TheFolderTheaspxPageIsIn/FileName.FileExtension .

If I try

<a href="~/FileUploads/"'<%# DataBinder.Eval(Container.DataItem, "Name")
%>'> <%# DataBinder.Eval(Container.DataItem, "Name") %>

it generates

http://localhost/MyWebApplication/TheFolderTheaspxPageIsIn/~/FileUploads/FileName.FileExtension

whereas I want

http://localhost/MyWebApplication/FileUploads/FileName.FileExtension

Any suggestions?

Thanks!

Lauchlan M
 
Figured it out.

<a href='<%# Server.MapPath("~/FileUploads/")%>
<%# DataBinder.Eval(Container.DataItem, "Name") %>'>
<%# DataBinder.Eval(Container.DataItem, "Name") %>
</a>

For anyone who'se interested.

Lauchlan M
 
Back
Top