I have the following code in a view (Demo.aspx) within a ASP.NET MVC 2 project:
Demo.aspx:
<% if (!Model.IsValid) { %><%= Model.FirstName %> - <% } %><%= Model.LastName %> -
I am trying to convert it to razor view (Demo.cshtml) in the process of migrating the project from ASP.NET MVC2 to ASP.NET MVC3. After doing some analysis and following the URL: http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx/ for migration of the webforms to razor view, I drafted the following code equivalent in razor view:
Demo.cshtml:
@if (!Model.IsValidName)
{ @Html.Raw(Model.FirstName)
@Html.Raw("-")
}
@Html.Raw(Model.LastName)
@Html.Raw("-")
But by using the conversion tool : http://visualstudiogallery.msdn.microsoft.com/d2bfd1ca-9808-417c-b963-eb1ea4896790 , I got the following code:
Demo.cshtml:
@if (!Model.IsValidName)
{ @Model.FirstName
@Html.Raw("-")
} @Model.LastName
@Html.Raw("-")
Can anyone help to confirm which of the above is correct?