I'm starting to use Asp.net MVC. It is recommended to use the <%
and %>
tags to embed the source code in the HTML, since it's easier to read.
Unfortunately though Visual Studio can't detect any errors in the code at compile time. This is a very bad thing.
For example:
<body>
<form action="LogOn.aspx">
<div>
<div><label for="txtLogOn_UserName"><%= LogOnView.UserName %> :</label></div>
<div><%= Html.TextBox("txtLogOn_UserName")%></div>
</div>
</form>
</body>
How can I be sure that LogOnView.UserName
is a valid statement? As an analogy that code is similar to JS code; you can't know if there will be errors until you run it.
A possible solution could be to create a test project, but I don't like that idea and I don't think I should be forced to create a test project to solve this problem.
Note: This problem will not occur if I use the code-behind coding style.