2

I want to store website addresses in a table in the database as either "http://some_website.com" or just as "some_website.com". Then in the view I have access to the text through "Model.Website". How can I generate a hyperlink? Is there a helper to do this?

user646306
  • 503
  • 1
  • 5
  • 16

1 Answers1

2

Simply embed the model properties in a hyperlink element appropriately:

public class YourModel
{
    public string Href { get; set; }
    public string LinkText { get; set; }
}

...

<a href="@Model.Href">@Model.LinkText</a>
Moho
  • 15,457
  • 1
  • 30
  • 31