tags:

views:

364

answers:

1

Given the MVC2 code below why is the second label getting mangled?

<%=Html.Label("DisplayFor(" + "DateHired,\"Date\"):") %>
<%=Html.Label("DisplayFor(" + "c=>c." + "DateHired,\"Date\"):") %>
<%=Html.DisplayFor(c=>c.DateHired,"Date") %>

results in:

DisplayFor(DateHired,"Date"):

DateHired,"Date"):

2/28/1999

+1  A: 

I think this is simply that you cannot use ">" in the text of HTML as it thinks it is markup.

instead use &gt;

i.e.

<%=Html.Label("DisplayFor(" + "c=&gt;c." + "DateHired,\"Date\"):") %>
h_a_z_
This doesn't work for me:<%=Html.Label("DisplayFor(c=>c.DateHired,\"Date\"):") %>results in:DateHired,"Date"):
alan