I have users list and want to bind that on top navigation bar, this will always visible for many pages, how i can bind it, i don't want to add code on each file, is there any method in mvc4 that is called for each view?
My view:
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Name Three<b class="caret"></b></a>
<ul class="dropdown-menu">
//Here i want to show data dynamically, data can be in collection.
<li><a href="#">Name one</a></li>
<li><a href="#">Name two</a></li>
<li><a href="#">Name Three</a></li>
<li><a href="#">Four</a></li>
</ul>
</li>
</ul>
</div>
Controller:
ICollection<Names> names = this.obj.GetNames();
In situations like this I prefer to use a code behind call to the view bag. try something like this
then on the controller where you want to put this method