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"">tekst</li> what doing wrong?
razor automatically html encodes string turns " ".
to turn off html encoding need use html.raw method (msdn):
<li @html.raw(addclasses())>tekst</li>
Comments
Post a Comment