I will like to achieve the following html using Html.ActionLink:
<li><a href="/WhatWeDo/JohnDoe">John Doe</a>President</li>
The name "John Doe" and title "President" will be coming from a staff model. This is what I have:
<% foreach (var item in Model as IEnumerable<AkwiMemorial.Models.Staff>)
{ %>
<li><%= Html.ActionLink(item.Name, "GetStaffDetails", "WhatWeDo", new { staffID = item.Id }, n开发者_StackOverflow社区ull) %> item.Position</li>
<% } %>
Instead of rendering "item.Position" literally, I will like this string extracted from the model.
TIA.
Try this:
<% foreach (var item in Model as IEnumerable<AkwiMemorial.Models.Staff>)
{ %>
<li>
<%= Html.ActionLink(item.Name, "GetStaffDetails", "WhatWeDo", new { staffID = item.Id }, null) %>
<%=item.Position%>
</li>
<% } %>
精彩评论