开发者

ASPX page response syntax

开发者 https://www.devze.com 2023-01-22 02:37 出处:网络
In the past I have always worked from the code behind page in ASP.NET and emitting all of my markup from that area.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消