Ok, so basically i have an form which edits data in my database. I have the following inputs:
<input value="@title" type="text" asp-for="@Model.ProjName" class="form-control" placeholder="Ticket1" />
<textarea value="@description" type="text" asp-for="@Model.ProjDescription" class="form-control" rows="3"></textarea>
I can pre-populate the input just fine, however value doesn’t work on the textarea. What is the correct way of populating it?
2
Answers
This will solve your problem. Text area acts differently from input tag . So instead of using value parameter, add your value between open and close tag of text area
Here is a .net fiddle with an example
https://dotnetfiddle.net/2TYEOk
Since you use
asp-for="@Model.ProjDescription"
,so the default value will be@Model.ProjDescription
,if you want to bind value with@description
,you can try to use id and name to replaceasp-for="@Model.ProjDescription"
.Here is the sample code: