Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET/MVC: Inline code

What am I doing wrong? How come <%= this %> isn't being interpreted as C#?

Here's the code : Hosted by imgur.com

And here is what it renders (notice the Firebug display): Hosted by imgur.com

What do you think is going on? MVC newb here. :(

And the static Site class: Hosted by imgur.com

(If you cannot see the screenshots on the page, view source and use the URLs from the <img> tags.)

like image 254
JamesBrownIsDead Avatar asked Mar 22 '26 14:03

JamesBrownIsDead


2 Answers

<%: %> starts with .NET v4

For pre-v4 it's equivalent is <%= Html.Encode(...) %>

like image 141
zerkms Avatar answered Mar 25 '26 03:03

zerkms


The problem was that I was using <%= %> (or even <%: %>) within a tag that had runat="sever".

like image 24
JamesBrownIsDead Avatar answered Mar 25 '26 02:03

JamesBrownIsDead



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!