Render Html from a lambda in MVC
Posted
by Thad
on Stack Overflow
See other posts from Stack Overflow
or by Thad
Published on 2010-04-22T21:26:07Z
Indexed on
2010/04/22
21:53 UTC
Read the original article
Hit count: 264
I have the following code to generate a list and will allow developers to customize the output if needed.
<% Html.List<MyList>(item => item.Property).Value(item => return "<div>" + item.Property + "<br/>" + item.AnotherProperty + "</div>").Render() %>
This is not ideal, how can I allow the developers to add the html similar to other controls.
<% Html.List<MyList>(item => item.Property).Value(item => %> <div><%=item.Property%><br/><%=item.AnotherProperty%></div><%).Render() %>
This way is much cleaner and standard with the rest of mvc.
© Stack Overflow or respective owner