79303679

Date: 2024-12-23 16:38:59
Score: 1
Natty:
Report link

This is a kind of a fucked up gotcha. The TagHelper asp-for="Data.OutputText" does not in fact refer to the PageModel’s Data property, but to an entry in the its ModelState dictionary.

Since your output textarea doesn’t need to be part of the form in the first place, I would just skip the TagHelper business and write

<textarea id="outputText" class="form-control" rows="5" readonly>@Model.Data.OutputText</textarea>

Honestly I would prefer writing my own HTML in general, but that’s just me.

You could also do this if you really hate HTML:

@Html.TextArea(Model.Data.OutputText, Model.Data.OutputText, 5, 0, new { @class = "form-control", required = false, @readonly = true, id = "outputText" })
Reasons:
  • Blacklisted phrase (2): fuck
  • Long answer (-0.5):
  • Has code block (-0.5):
Posted by: BenderBoy