TextAreaTagHelper : 可以换(多)行的输入框,为.net 对html 的封装。
新增一个TextAreaController 跟相应View和 ViewModel
TextAreaController.cs
using Microsoft.AspNetCore.Mvc;
using Net5App6.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Net5App6.Controllers
{
public class TextAreaController : Controller
{
public IActionResult Index()
{
return View();
}
[HttpPost]
public IActionResult Index(TextAreaViewModel model)
{
string content = model.Content;
return View(model);
}
}
}
Index.cshtml
@model TextAreaViewModel
<form method="post">
<div>
<textarea asp-for="Content"></textarea>
</div>
<div>
<input type="submit" value="提交" />
</div>
</form>
TextAreaViewModel.cs
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace Net5App6.Models
{
public class TextAreaViewModel
{
[Display(Name = "多行输入框")]
public string Content { get; set; }
}
}
运行效果
本篇已同步发表至个人部落格
https://coolmandiary.blogspot.com/2021/08/net-core20textareataghelper.html
>>: 找LeetCode上简单的题目来撑过30天啦(DAY5)
案例说明及适用场景 组织架构是由部门及职务做为骨架,员工就职於某一个职务 员工在企业的职务,就如同系...
今天继续来熟悉Unity介面~(ง •̀_•́)ง‼ 昨天了解了阶层管理区,今天打算接续着看游戏执行...
发达的工具会剥夺人的能力,能力被剥夺後经验会开始狭隘,狭隘的经验则会让思维开始产生死角,有死角的思维...
接下来的测试将会需要用到 mocking 的 library ,在 Android 大家比较常用的是...
前述 今天来画个时钟~!一样利用 requestAnimationFrame,再判断当前时间,每一秒...