上一节大概了解了MVC的运作方式。这一届发一个简单样例,在网页界面中的文本框输入一个值,在后台控制器中进行接收,然后跳转到另一个页面。
一:要发送数据的视图
在HomeController中新建一个视图
public ActionResult MyView()
{
return View();
}
右键点击MyView()选择新添视图。(刚开始把选择母版页的勾去掉吧)
二:要从视图中接收数据的方法
(这里不用添加视图)
public ActionResult FromView(FormCollection formCollection)
{
var str = Request["txtName"]; //接收值
//返回控件里 txtName 的值到新的视图页面中
//return Content(Request["txtName"]);
//跳转到Index的方法中
return RedirectToAction("Index");
//跳转到Index的视图中
//return View("Index");
}
三:在视图页面中发送数据
MyView.aspx下:
<body>
<div>
<form action="/Home/FromView" method="post" enctype="application/x-www-form-urlencoded">
姓名:<input type="text" name="txtName" /><br />
<input type="submit" value="确定" />
</form>
</div>
</body>
//action为发送到的“地点”,method类型为发送,enctype可以省略~
分享到:
相关推荐
Ext.NET.MVC.Pro.2.2.0.MVC.Examples.Explorer 包含了所有你需要的控件DEMO。
Manning.ASP.NET.MVC2.in.Action 和Apress.Pro.ASP.NET.MVC.2.Framework.2nd.Edition.Jun.2010 两本经典的
Pro.ASP.NET.MVC.5.5th.EditionPro.ASP.NET.MVC.5.5th.EditionPro.ASP.NET.MVC.5.5th.Edition
Ext.NET.MVC.Pro.2.2.0.zip 官网下载的
ASP.NET.MVC2.in.Action Every once in a while, if you are lucky, you may get to see history in the making. For me, one of those moments occurred in October of 2007. I sat on the floor of a filled to ...
[ASP.NET.MVC系列].ASP.NET.MVC.in.Action
Manning.ASP.NET.MVC2.in.Action.pdf
开发实践篇通过一套完整的留言板系统案例详述ASP.NET MVC 2的开发技巧与流程,以及ASP.NET MVC的安装部署和单元测试方法。 《ASP.NET MVC 2开发实战》适合对MVC架构感兴趣的ASP.NET开发人员阅读。 作者简介 黄保翕...
AngularJS 开发 ASP.NET MVC.
Packt.ASP.NET.Core.MVC.2.0.Cookbook.2018 Packt.ASP.NET.Core.MVC.2.0.Cookbook.2018
Microsoft.Press.Programming.Microsoft.ASP.NET.MVC3.2011.2nd.Ed
Chapter 2: Model View Controller and ASP.NET. Chapter 3: ASP.NET > ASP.NET MVC. Chapter 4: Routes and URLs. Chapter 5: Controllers. Chapter 6: Views. Chapter 7: AJAX. Chapter 8: Filters. ...
Ext.NET.MVC.Pro.2.5 Examples
Professional ASP.NET MVC 3: Describes what views are and explores the Razor syntax, NuGet, unit testing, and much more Explains the role of Controllers in the MVC framework and what role models play...
[精通ASP.NET.MVC.5框架(第五版)].Apress.Pro.Asp.Dot.NET.MVC.5.5th.edition 官方原版英文版,高清无水印,文字清晰。
ASP.NET MVC5 官网下载源码.rar ASP.NET MVC5 官网下载源码.rar ASP.NET MVC5 官网下载源码.rar ASP.NET MVC5 官网下载源码.rar ASP.NET MVC5 官网下载源码.rar ASP.NET MVC5 官网下载源码.rar
Combine the power of ASP.Net MVC 6 with Bootstrap 4 to build elegant, responsive web apps About This Book Updated for Bootstrap 4 and ASP.Net MVC 6, this book shows how to take advantage of the ...
Pro.ASP.NET.MVC.4.4th.Edition.pdf 最好的ASP.NET MVC教材
Apress.Pro.ASP.NET.MVC3.Framework.3rd.Ed