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

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
 
L

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top