worked
worked

Reputation: 5880

Razor + Html.Raw() with white space?

Why does the following work:

@if(Page.SomeVar == "VALUE"){
    @Html.Raw(".classStyle{border:1px solid #000} #idStyle{border:1px solid #000}")
}

Yet this breaks:

@if(Page.SomeVar == "VALUE"){
    @Html.Raw("
       .classStyle{border:1px solid #000}
       #idStyle{border:1px solid #000}
    ")
}

Upvotes: 2

Views: 1955

Answers (1)

nemesv
nemesv

Reputation: 139778

This has nothing to do with Razor in C# you need to use @ if you want to have multiple line string literals

@if(Page.SomeVar == "VALUE"){
    @Html.Raw(@"
       .classStyle{border:1px solid #000}
       #idStyle{border:1px solid #000}
    ")
}

Upvotes: 3

Related Questions