Reputation: 1435
I have a layout page that I applied for most of my views.
Now I'm asked to place a website logo + link
in my homepage. The problem is the <a> tag
must be placed in a div
tag (the left menu) in my layout
view.
If I place the link in my layout
view, the link will appear in most of my pages, but I only need it to be appeared only in my homepage
Now the question is how do I add/modify the layout div
tag to insert the link+logo from my home page view (Home/Index.cshtml) ?
Upvotes: 1
Views: 35
Reputation: 7742
You could do this :
public HomeController : Controller
{
public ActionResult Index()
{
ViewBag.HomeLink = "http://some.com"
}
}
then in the Layout
check if ViewBag.HomeLink
exists and just render the anchor. That way only the home page will get the link rendered.
Upvotes: 2