Simbian
Simbian

Reputation: 21813

What is the differences in rendering in asp.mvc

What is the differences in operators for render server code?

Operator: <%@
Operator: <%:
Operator: <%=

Upvotes: 6

Views: 106

Answers (2)

Jonas H&#248;gh
Jonas H&#248;gh

Reputation: 10874

<%= 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.

Upvotes: 9

Lasse Edsvik
Lasse Edsvik

Reputation: 9298

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

Upvotes: 1

Related Questions