本文转自:http://www.cnblogs.com/mayt/archive/2010/05/20/1740358.html首先是创建一个类,继承于ActionResult,记住要引用System.Web.Mvc命名空间,如下:public class ImageResult : ActionR...
分类:
数据库 时间:
2014-06-28 23:27:57
阅读次数:
202
假设控制器方法参数类型是int: public ActionResult GetSth(int id) { return Content(id.ToString()); }而视图传递过来的是字符串:@Html.ActionLink("获取","GetSth",new {id="hello"})于是就...
分类:
Web程序 时间:
2014-06-28 14:23:44
阅读次数:
447
public ActionResult GetForm() { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; if (Fi.....
分类:
其他好文 时间:
2014-06-21 08:15:22
阅读次数:
279
1、ViewData对象 ViewBagData是一种字典集合数据同时属于视图基类和控制器基类的属性。 实例: //控制器public class HomeController:Controller{ public ActionResult Index() { ...
分类:
Web程序 时间:
2014-06-19 06:48:39
阅读次数:
402
如果创建如下的XML: darren 创建XML文件在HomeController中,在根目录下创建new.xml文件:public ActionResult Index() { return View(); } [HttpPost] public ActionResult AddXml() ...
分类:
Web程序 时间:
2014-06-18 22:08:31
阅读次数:
176
//调用
public ActionResult GenerateExcel() {
DataTable headerTable = new DataTable();
headerTable.Columns.Add("Status_Id", Type.GetType("System.String"));
header...
分类:
其他好文 时间:
2014-06-15 10:28:57
阅读次数:
260
摘要MVC框架针对HttpResponse进行抽象与多态,使HttpResponse均可表示为ActionResult。那么,抽象和多态表现在哪里呢?//封装一个Action的结果.public
abstract class ActionResult{ protected ActionResu...
分类:
Web程序 时间:
2014-06-08 00:17:18
阅读次数:
321
今天接触了mvc4.0项目,View中需要获取从Control传来的json数据。过程记录如下:在MVC返回的ActionResult中,为我们提供了JSONResult(继承至ActionResult)对象,我们可以直接用他来返回JSON对象给View处理将自定义的Model实例传给Json方法,...
分类:
Web程序 时间:
2014-06-06 20:22:22
阅读次数:
332
与MVC3相比,差别很大: public ActionResult Main() { List
items = new List(); items.Add(new SelectListItem { Text = "Action", Value...
分类:
Web程序 时间:
2014-06-02 01:34:06
阅读次数:
338
public ActionResult Index(int? pageIndex) { List
data = new List(); for (int i = 0; i pagedList = new PagedList(data.As...
分类:
Web程序 时间:
2014-05-26 19:52:39
阅读次数:
279