AspNet MVC4 teaching -22:asp.net MVC4 Partial View Technology Quick Application Demo

Source: Internet
Author: User

A. Create an MVC project of the basic type.

B.model directory, create the file:

LoginModel.cs:

Using system;using system.collections.generic;using system.linq;using system.web;namespace mvcpartialviewtest.models{public    class Loginmodel    {public        string Name         {            get            {                return} "Zhang San";            }                }        public string  Remark        {            get            {                return ' flight student. ';            }        }          Public double score        {            get            {                return 99.12;            }    }}

C. Create a HomeController.cs file:

Using system;using system.collections.generic;using system.linq;using system.web;using System.Web.Mvc;using Mvcpartialviewtest.models;namespace mvcpartialviewtest.controllers{public    class Homecontroller:controller    {        ////        GET:/home/public        actionresult Index ()        {                              Viewdata.model = new Loginmodel ();            return View ();        }        Public ActionResult Getpartialview ()        {            return Partialview ("Partiallink");        }    }

C. Create the appropriate Partialview:

1) PartialLink.cs:

<a href= "http://www.sina.com.cn" > Sina </a> <a href= "http://www.sohu.com" > Sohu </a> <a href= " http://www.exesoft.cn "> Easy software </a>
2) Partialdatafromloginmodel.cshtml:
@using Mvcpartialviewtest.models@model loginmodel

3) Partialdatafromview.cshtml:

@model system.double

D. Create the View file:

Index.cshtml:

@using Mvcpartialviewtest.models@model loginmodel@{    viewbag.title = "Index";} 
E.:



AspNet MVC4 teaching -22:asp.net MVC4 Partial View Technology Quick Application 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.