2

I have a model passed into a cshtml view, and I'm trying to create a variable with a string from the model. The problem is that the string contains newlines, and when I create the variable, the newlines are not converted, and I end up with an Unterminated string constant error in the Javascript.

Currently I'm doing this:

var something = @Model.string;

How can I pass the model attribute so that new lines are preserved in the javascript variable?

7

1 Answer 1

0

It might help you:

var something = @:Model.ToString();
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.