Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Encoding Blocks - Invalid expression term ':'

I'm developing a new ASP.NET MVC 2.0 application and wanting to use the new ASP.NET 4 encoding blocks.

My View code contains <%: Model.ActivityName %> however Visual Studio is reporting:

Unexpected token

at the position of the : (colon). When I run the application I get the following compilation error:

Compiler Error Message: CS1525: Invalid expression term ':'

What am i missing?

Cheers for any help/advice.

like image 964
Jamie Dixon Avatar asked May 07 '10 16:05

Jamie Dixon


1 Answers

This feature is new to ASP.Net 4.0, which is in turn new to Visual Studio 2010.

In earlier versions, you should write

<%= Html.Encode(Model.ActivityName) %>
like image 116
SLaks Avatar answered Oct 03 '22 03:10

SLaks