Robert Koritnik
Robert Koritnik

Reputation: 105039

Is it possible to use <%: in .net framework 3.5

This may be a duplicate of some other question, but it's hard to search the web for <%: so I can't really find anything.

When I created a new Asp.net MVC 2 project its templates use the new notation of automatic html encoding. WHen I changed .net framework target to 3.5, these server scripts stopped working. When I changed them to <%= everything was fine, but it's not the same.

Anyway. Is it possible to take advantage of this notation and avoid writing tedious and long statements <%= Html.Encode(...) %>?

Upvotes: 1

Views: 91

Answers (2)

Garett
Garett

Reputation: 16828

Unfortunately it is not possible. It is mentioned in the following article. See the section titled Helpers now return an MvcHtmlString object. Also, see the explanation from Phil Haack as to why.

Upvotes: 3

marc_s
marc_s

Reputation: 754778

As far as I know, this is an ASP.NET 4.0 only feature - so on 3.5, you still need to remember to use the Html.Encode(.....)..... another good reason to upgrade! :-)

Upvotes: 1

Related Questions