Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Add double quotes inside a string

$
0
0

For if Model.Class is not null, add the string value for Model.Class inside a class="" - I'm trying to output this: class="class1 class2"

The problem is that I want to add quotes in case there are multiple class names. EpiServer isn't letting me do this. Here's what I've tried...

  1. @(Model.Class != null ? @"class=""" + Model.Class + @"""" : "")
    Renders class="class1 class2"

  2. @(Model.Class != null ? "class='" + Model.Class + "'" : "")
    Renders the single quote as "

  3. @(Model.Class != null ? "class=\"" + Model.Class + "\"" : "")
    Renders the same as #1 above.

Is this possibly an issue with my local version of Epi? I'm not a programmer and I don't know how Epi was set up for my company. Is there something else I should try? Thank you!


Viewing all articles
Browse latest Browse all 9076

Trending Articles