user1531040
user1531040

Reputation: 2291

How can I create a hyperlink for the referring website using MVC?

I have a row on my website (MVC)

<td width="80%" align="left"><%: Html.DisplayFor(model => model.Website)%></td>

And I want to couple a hyperlink on that row. How can I create a hyperlink for the referring website?

Upvotes: 0

Views: 117

Answers (2)

balexandre
balexandre

Reputation: 75073

Just use a normal anchor <a> tag

<td width="80%" align="left">
   <a href="<%: model.Website %>" target="_blank"><%: model.Website %></a>
</td>

if your value does not have http at the beginning, just manually add it, like:

<a href="http://<%: model.Website %>" ...

Upvotes: 3

trailmax
trailmax

Reputation: 35106

You can create display template for that if you want to be fancy or you have a lot of links on your site. See example for that: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html

Upvotes: 2

Related Questions