- I want to insert a user control on to a master page
- The user control is a basic menu that lists categories of items
- I want to pull the category list dynamically from SQL Server
- I can do this in web forms using code behind, but how do you go about this in MVC? Thank you
Categories.ascx:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<ul>
<% foreach (string category in Model.Categories ) { %>
<li>
<%= Html.Encode(category) %>
</li>
<% } %>
</ul>