ASP.NET MVC控制器向视图传值有哪些方法?
- 内容介绍
- 文章标签
- 相关推荐
本文共计2231个文字,预计阅读时间需要9分钟。
一、准备工作 + 创建一个ASP.NET MVC程序,然后在Models文件夹中新增Student实体类,用于模拟从Controller向View传递数据,Student类定义如下:using System; using System.Collections.Generic; using System;
一、准备工作
创建一个ASP.NET MVC程序,然后在Models文件夹里面新添加Student实体类,用来模拟从Controller向View传递数据,Student类定义如下:
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MVCStudyDemo.Models { public class Student { public int ID { get; set; } public string Name { get; set; } public int Age { get; set; } public string Sex { get; set; } public string Email { get; set; } } }
二、通过ViewData传值
MVC从开始版本就一直支持使用ViewData将Controller里面的数据传递到View。
本文共计2231个文字,预计阅读时间需要9分钟。
一、准备工作 + 创建一个ASP.NET MVC程序,然后在Models文件夹中新增Student实体类,用于模拟从Controller向View传递数据,Student类定义如下:using System; using System.Collections.Generic; using System;
一、准备工作
创建一个ASP.NET MVC程序,然后在Models文件夹里面新添加Student实体类,用来模拟从Controller向View传递数据,Student类定义如下:
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MVCStudyDemo.Models { public class Student { public int ID { get; set; } public string Name { get; set; } public int Age { get; set; } public string Sex { get; set; } public string Email { get; set; } } }
二、通过ViewData传值
MVC从开始版本就一直支持使用ViewData将Controller里面的数据传递到View。

