ASP.NET ntext 属性 的 MVC textarea 标签助手不工作
ASP.NET MVC textarea tag helper for ntext property is not working
我有一个以下模型 属性ies,其中一个是 projectDescription,它在 SQL 服务器中生成一个 ntext
列。
型号:
--some other properties here....
[Display(Name = "Project Title")]
[Column(TypeName = "varchar(125)")]
public string ProjectTitle { get; set; }
[Column(TypeName = "ntext")]
public string ProjectDesctiption { get; set; }
--some other properties here....
此 属性 绑定到 View
中的 textarea
标记,如下所示。但是,它并没有显示来自 Db 的 ProjectDesctiption
列的真实数据,而是奇怪地显示了查看页面的整个 html 源页面 - 如下图所示。其他标签正确显示数据,如下面同一图片中的 ProjectTitle 字段所示。我认为这个问题与 ntext 数据类型和 ASP Tag helper for textarea 有关。我确实在数据库中检查过 ProjectDescription 中某些数据单元格的最大长度相当大——大约 61968 个字符。但是我们确实希望以合理的文本区域长度和宽度以及水平和垂直滚动条显示此列中的数据,以便用户至少可以浏览此字段的数据以了解项目描述是什么(例如)或出于某种目的,可能是 copy/past 来自 textrea 的数据。 问题:我怎样才能实现这个目标?
查看:
---some html here.....
<div class="form-group">
<label asp-for="ProjectTitle" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="ProjectTitle" class="form-control" />
<span asp-validation-for="ProjectTitle" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="ProjectDesctiption" class="col-md-2 control-label"></label>
<div class="col-md-10">
<textarea asp-for="ProjectDesctiption" class="form-control" rows="6" cols="15" />
<span asp-validation-for="ProjectDesctiption" class="text-danger"></span>
</div>
</div>
...some other html here...
<textarea>
不是自闭标签,因为您没有 'closed' 它,它显示标签后面的 html。
将您的代码更改为
<textarea asp-for="ProjectDesctiption" class="form-control" rows="6" cols="15"></textarea>
我有一个以下模型 属性ies,其中一个是 projectDescription,它在 SQL 服务器中生成一个 ntext
列。
型号:
--some other properties here....
[Display(Name = "Project Title")]
[Column(TypeName = "varchar(125)")]
public string ProjectTitle { get; set; }
[Column(TypeName = "ntext")]
public string ProjectDesctiption { get; set; }
--some other properties here....
此 属性 绑定到 View
中的 textarea
标记,如下所示。但是,它并没有显示来自 Db 的 ProjectDesctiption
列的真实数据,而是奇怪地显示了查看页面的整个 html 源页面 - 如下图所示。其他标签正确显示数据,如下面同一图片中的 ProjectTitle 字段所示。我认为这个问题与 ntext 数据类型和 ASP Tag helper for textarea 有关。我确实在数据库中检查过 ProjectDescription 中某些数据单元格的最大长度相当大——大约 61968 个字符。但是我们确实希望以合理的文本区域长度和宽度以及水平和垂直滚动条显示此列中的数据,以便用户至少可以浏览此字段的数据以了解项目描述是什么(例如)或出于某种目的,可能是 copy/past 来自 textrea 的数据。 问题:我怎样才能实现这个目标?
查看:
---some html here.....
<div class="form-group">
<label asp-for="ProjectTitle" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="ProjectTitle" class="form-control" />
<span asp-validation-for="ProjectTitle" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="ProjectDesctiption" class="col-md-2 control-label"></label>
<div class="col-md-10">
<textarea asp-for="ProjectDesctiption" class="form-control" rows="6" cols="15" />
<span asp-validation-for="ProjectDesctiption" class="text-danger"></span>
</div>
</div>
...some other html here...
<textarea>
不是自闭标签,因为您没有 'closed' 它,它显示标签后面的 html。
将您的代码更改为
<textarea asp-for="ProjectDesctiption" class="form-control" rows="6" cols="15"></textarea>