Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the differences in rendering in asp.mvc

What is the differences in operators for render server code?

Operator: <%@
Operator: <%:
Operator: <%=
like image 563
Simbian Avatar asked Nov 24 '10 13:11

Simbian


2 Answers

<%= simply evaluates an expression and writes the result to the page output

<%: is the same, but also HTML encodes the output - unless the output implements IHtmlString

<%@ is for special framework directives, e.g. <%@ Page for specifying page attributes such as the master page

<% is for code blocks that are statements, not expressions. These will not generate page output unless you explicitly call a function that writes to the output.

<%# is for data-binding expressions, which are evaluated when a webforms control is databound. They are therefore rarely used in MVC.

like image 67
Jonas Høgh Avatar answered Nov 24 '22 08:11

Jonas Høgh


<%: html-encodes the result <%= is equal to Response.Write <%@ is an preprocessor derictive

like image 20
Lasse Edsvik Avatar answered Nov 24 '22 07:11

Lasse Edsvik