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

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -