• ASP.NET MVC2 in Action 读书笔记 [91] ChildAction


    1). ChildAction

    HomeController.cs:

    [HandleError]
        public class HomeController : Controller
        {
            public ActionResult Index()
            {
                ViewData["Message"] = "Welcome to ASP.NET MVC!";
     
                return View();
            }
     
            [ChildActionOnly]
            public ActionResult ChildAction()
            {
                return View();
            }
        }

    Index.aspx:

    <h2><%= Html.Encode(ViewData["Message"]) %></h2>
        <p>
            To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
        </p>
        <%Html.RenderAction("ChildAction"); %>

    ChildAction.aspx:

    <%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
     
    <h2>This view was rendered by calling RenderAction. This is a ChildAction</h2>
     
  • 相关阅读:
    QuickFlash
    第五课:类的封装性 M
    第六课:构造方法、匿名对象 M
    第四课:面向对象(基础) M
    第八课:引用传递 M
    第七课:String类 M
    第二课:数组 M
    第三课:方法 M
    ASP .Net的应用程序域(The Application Domain)
    js 解数独程序
  • 原文地址:https://www.cnblogs.com/RobotTech/p/2123800.html
Copyright © 2020-2023  润新知