In asp.net mvc, when do we use:
and
Do we ever need to put a ; (colon) ?
<%= %>
renders the output (string) of the contained command to the response. <% %>
wraps executable statements (logic) in the view to control what gets executed. You don't use semicolons in the <%= %>
blocks, but may in the <% %>
depending on what statements are included.
String rendering:
<%= Html.Encode( Model. Property ) %>
Code block:
<% Html.RenderPartial( "ViewName" ); %>
EDIT: Here's a link to the reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With