.NET Core 中MVC项目

后台传值前台的方式:

第 一种:后台:ViewData["shan"]  前台:  @ ViewData["shan"]

第 二种:后台:ViewBag.shan    前台:@ ViewBag.shan

第三种:后台:1、List<UserTable>2、return View(list);前台:1、抬头定义@model List<UserTable>和定义using控制器的名称@using WebApplication1.Controllers 2、标签中使用@Model[0].Sex;

第四种:后台:usertable c=new usertable{name=山东,id=1} 前台:1、抬头定义using表类的名称@model WebApplication1.Controllers 2、标签中使用@Model[0].Sex;

 

 

前台传值后台的方式:

第一种:<from  action="saysth " method="post"></from>绑定的是表的实体类,后台对实体类操作,

第二种:<from  action="Home/index " method="post"></from>绑定的是控制器下面的方法,后台方法里要定义接受参数的名称

第三种:@using (Html.BeginForm("styse", "tow"))//styse是控制器下的方法名称,tow控制器名称 {<input type="text" name="sex" id="sex" />   <input type="submit" value="提交" />}

 

posted @ 2021-06-29 16:08  猴猴手记  阅读(177)  评论(0编辑  收藏  举报
浏览器标题切换
浏览器标题切换end