ASPX page response syntax
In the past I have always worked from the code behind page in ASP.NET and emitting all of my markup from that area.
I am now learning MVC and am working in the .ASPX page direc开发者_开发技巧tly.
The following statements can be written...
<%= Html.Label("Test") %>
<%: Html.Label("Test")%>
<% Html.Label("Test"); %>
The first two emit the word 'Test', while the 3rd doesn't do anything. Yet no errors are thrown.
I seem to recall <%= is shorthand for <% Response.Write("") %>. Is <%: the same shortcut?
I suppose the 3rd statment runs, but simply returns a string that is discarded.
You are right about 1 and 3. 2 does as one, but it html escapes the output.
精彩评论