Is there a good reason to use the strongly typed html helper…
<%: Html.DisplayTextFor(model => model.Email) %>
As opposed to…
<%: Model.Email %>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Consider the following Model:
in my view:
The first line will display “No value available” if we leave the Email to be ‘null’ whereas the second line will not display anything.
Conclusion:
Html.DisplayTextFor will take into consideration the DataAnnotations on your properties,
<%: Model.Email %>will not.Also
<%: Model.Email %>will throw an “Object reference error” when the value is null, but<%= Html.DisplayTextFor %>wont.