The AspNet MVC4 teaching -25:asp.net MVC4 Strength type View and other technologies quick comparison Demo

Source: Internet
Author: User

A. Create A basic type project.

Create 4 class files under the B.model directory:

Teacher.cs:

Using system;using system.collections.generic;using system.linq;using system.web;namespace MvcViewModelTest.Models{ Public    class Teacher    {public        string Name        {            get            {                return ' Miss Ma ';            }        }        public string Remark        {            get            {                return ' computer teacher ';            }    }}}
Student.cs:
Using system;using system.collections.generic;using system.linq;using system.web;namespace MvcViewModelTest.Models{ Public    class Student    {public        string Name        {            get            {                return ' Zhang San ';            }        }        public string Remark        {            get            {                return "e-commerce Student";}}    }
AllPersons.cs:
Using system;using system.collections.generic;using system.linq;using system.web;namespace MvcViewModelTest.Models{ Public    class Allpersons    {public        Teacher tea=new Teacher ();        Public Student stu=new Student ();}                 }
Other.cs:
Using system;using system.collections.generic;using system.linq;using system.web;namespace MvcViewModelTest.Models{ public class other    {public        string Name        {            get            {                return ' John Doe ';            }        }        public string Remark        {            get            {                return ' logistic staff ';            }    }}}
C. Create HomeController.cs:

Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.Mvc;using Mvcviewmodeltest.models;namespace mvcviewmodeltest.controllers{public    class Homecontroller:controller    {        ////        GET:/home/public        actionresult Index ()        {            viewbag.other = new Other ();            Return View (New Allpersons ());}}}       
d.view/home/Create 1 files:

Index.cshtml:

@using Mvcviewmodeltest.models@model allpersons@{viewbag.title = "Index"; }

E::


The AspNet MVC4 teaching -25:asp.net MVC4 Strength type View and other technologies quick comparison Demo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.