如何在 ASP.Net Core 的 textarea 中显示纯文本而不是 HTMLText
How to display plain text instead of with HTMLText in textarea in ASP.Net Core
如何在 ASP.Net Core
的文本区域中显示纯文本而不是 HTMLText
这是我的看法
<div class="form-group row">
<label asp-for="Decription" class="col-sm-3 col-form-label">Description</label>
<div class="col-sm-7">
<textarea type="text" asp-for="Decription" class="form-control"></textarea>
</div>
</div>
这是我的观点
如何在此 textarea 而不是 HtmlText 中显示纯文本。
如果您想要不带任何格式地显示您的内容,您可以使用 Regex.Replace(input, "<.*?>", String.Empty)
从您的字符串中删除所有 Html 标签。
您可以在后台更改:
var model = new TestModel() {
Decription="<p><strong>Test</strong> is a Special Item in our <i>Restraunt</i>.</p>"
};
model.Decription = Regex.Replace(model.Decription, "<.*?>", String.Empty);
或前端更改:
@model TestModel
@using System.Text.RegularExpressions;
<textarea type="text" name="Decription" class="form-control">@Regex.Replace(Model.Decription, "<.*?>", String.Empty)</textarea>
如何在 ASP.Net Core
的文本区域中显示纯文本而不是 HTMLText这是我的看法
<div class="form-group row">
<label asp-for="Decription" class="col-sm-3 col-form-label">Description</label>
<div class="col-sm-7">
<textarea type="text" asp-for="Decription" class="form-control"></textarea>
</div>
</div>
这是我的观点
如何在此 textarea 而不是 HtmlText 中显示纯文本。
如果您想要不带任何格式地显示您的内容,您可以使用 Regex.Replace(input, "<.*?>", String.Empty)
从您的字符串中删除所有 Html 标签。
您可以在后台更改:
var model = new TestModel() {
Decription="<p><strong>Test</strong> is a Special Item in our <i>Restraunt</i>.</p>"
};
model.Decription = Regex.Replace(model.Decription, "<.*?>", String.Empty);
或前端更改:
@model TestModel
@using System.Text.RegularExpressions;
<textarea type="text" name="Decription" class="form-control">@Regex.Replace(Model.Decription, "<.*?>", String.Empty)</textarea>