asp.net - why a string is added in wrong format to the razorview? -


i'm trying add few classes listitem object in html using razor , helper method.

i defined @functions{} section method :

public string addclasses() {       return "classes=\"class1 class2\""; } 

when using in razor

<li @addclasses()>tekst</li> 

the result is:

<li class=""class1" class2&quot;">tekst</li> 

what doing wrong?

razor automatically html encodes string turns " &quot;.

to turn off html encoding need use html.raw method (msdn):

<li @html.raw(addclasses())>tekst</li> 

Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -