0

I had this, and got "Howdy, "

<p> Howdy, <% Model.ToString(); %> </p>

I changed it to

<p> Howdy, <%: Model.ToString() %> </p>

and got "Howdy, Chris". (Which is what I expected.) I found several pages that listed the different kinds of inline expressions, but none of the ones that I found listed the one with the colon, and googling "<%:" doesn't seem to find anything ;).

Thanks much

Lundin
  • 195,001
  • 40
  • 254
  • 396
basilard99
  • 307
  • 2
  • 12

3 Answers3

1

http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx

Nathan Ratcliff
  • 1,392
  • 12
  • 15
1
<% string name = "<strong>basilard99</strong>"; %>
Welcome <% name; %>!

Renders Welcome !

Welcome <% Response.Write(name); %>!
Welcome <%= name %>! <!-- Same thing -->

Renders Welcome <strong>basilard99</strong>!

Welcome <% Response.Write(Server.HtmlEncode(name)); %>!
Welcome <%: name %> <!-- Same thing -->

Renders Welcome &lt;strong&gt;basilard99&lt;/strong&gt;!

Mike Richards
  • 5,557
  • 3
  • 28
  • 34
0

Have a look here:

http://haacked.com/archive/2009/09/25/html-encoding-code-nuggets.aspx

And here too: Are <%: and <%= the same thing as embbed code (expression) blocks

Community
  • 1
  • 1
Dhruv
  • 952
  • 1
  • 11
  • 26