FormActionTagHelper (窗体操作标记帮助程序) : 其非针对原生HTML任何TAG对应的封装,功能是生成formaction属性
在<button>、<input type=image>tag中,
用於
控制<form>中在何处提交资料。换言之,可以不一定将action属性设置URL跳转固定放在<form>tag层级当中。(一个表单可以提交至不同server上进行处理)
新建好FormActionController跟相应Index检视
预设我们可以观察到在<button>有产生对应formaction各自对应不同导向URL
接下来调整一下检视,提交表单<button>必须放置於<form>里面才能提交。
新增TeacherController.cs
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Net5App6.Controllers
{
public class TeacherController : Controller
{
public string Home(string name, string age)
{
return $"Teacher控制器下的Home Action, 名字:{name},年龄:{age}";
}
}
}
新增StudentController.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 StudentController : Controller
{
public IActionResult Info(string name,string age)
{
ViewBag.Name = name;
ViewBag.Age = age;
return View();
}
}
}
Info View
<div>
<p>Student Info</p>
<p>@ViewBag.Name</p>
<p>@ViewBag.Age</p>
</div>
本篇已同步发表至个人部落格
https://coolmandiary.blogspot.com/2021/08/net-core22formactiontaghelper.html
删除档案的部分,首先要先把栏位列印出来 资料表一样参考第23天的文章 https://ithelp....
修复老照片 教学原文参考:修复老照片 这篇文章会介绍在 GIMP 使用「仿制工具」和「着色滤镜」,将...
从学校拿到一块DE2_115,之前修DCLAB的时候只有接触Verilog的部分,现在想要学习板子上...
要将自己开发的应用程序容器化,想必需要制作自己的 Image。制作 Image 也是一种艺术,我们要...
本文同步更新於blog 情境:这是公司生产的文字积木 <?php namespace Ap...