0

I want to show a string value with \n\r in a textarea.

I set this in jquery with Model

var content = "@Model.Content";
$("#ListContainer #@Html.IdFor(model => model.Content)").val(content);

I use '' , `` for @Model.Content but get error

i get error "" string literal contains an unescaped line break

how can i show this?

enter image description here

6
  • Use backticks to make it s template literal var content = `@Model.Content`; Commented Oct 29, 2023 at 8:45
  • thanks, i use this but dont ok Commented Oct 30, 2023 at 6:03
  • Please right-click on the page, click inspect, go to console and click the link to the part that gives error and screenshot the result (you can edit personal information before) Commented Oct 30, 2023 at 6:37
  • And now do the same for the actual source code se in "view-source" or using "inspect" so we can see the part of the script where you have the problem. My guess is it is not where you think it is Commented Oct 30, 2023 at 6:48
  • when i set a default text , $("#ListContainer #@Html.IdFor(model => model.Content)").val('sss'); it is ok , or when i replace content \r\n with '' it is ok. or set a value without break line it is ok' Commented Oct 30, 2023 at 6:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.