Is there a way to populate an anchor tag’s href value in the View using a ViewBag value? What I want to be able to do is something like this:
View:
<a href="<%= ViewBag.MyURL %>" title="My URL">"<%= ViewBag.MyURL %>"</a>
Controller:
public ActionResult Index()
{
ViewBag.MyURL = "http://www.Google.com";
return View();
}
How do I go about doing this correctly?
Thanks!
Here was the way this worked to dynamically update a href anchor tag using MVC and Razor:
Controller (this could also be set in a code block within the View if needed as well):
View: