超文本标记语言的核心可以很好地显示其中的数据,但是当我使用<textarea>时,它不能工作,它可能不能与asp- <input>一起工作,但我仍然被迫使用asp-<input>,因为我正在使用.NET核心来构建网页。
这是出现故障的输出代码(.cshtml)
@foreach (ComplaintManagement.Context.notesData note in ViewBag.getID)
{
<label>Subject</label>
<input required="required" class="form-control" asp-for="subject" value="@note.subject" />
<label>Summary</label>
<textarea class="form-control mb-2" asp-for="summary" rows="10">@note.summary</textarea>
}如果我没能解释清楚我的意思,希望我附上的图片能帮到你…

如果需要更多信息,请在评论区提问。
发布于 2020-09-22 15:46:58
我自己找到了答案,而不是使用asp-因为我使用了
<label>Summary</label>
<textarea class="form-control mb-2" rows="10" name="@Html.NameFor(m => m.summary)">@note.summary</textarea>在文本区域中使用name=""而不是asp-for=""解决了这个问题。
发布于 2020-09-18 20:01:13
正常情况下:
<textarea name='awesome'>Default value</textarea>但在你的案例中:
使用asp- .NET的.NET核心开发人员必须使用模型类中的构造函数来设置默认值。
示例:
public class Service()
{
public string Description { get; set; }
//other properties
public Service() //the constructor
{
Description = "Put the default value here!";
//other default values
}
}https://stackoverflow.com/questions/63955260
复制相似问题