zoukankan      html  css  js  c++  java
  • ASP.NET MVC 页面模块编程语法小结

    1.@RenderSection("XXX") 与 @section XXX{}

     _Layout.cshtml 

    <!DOCTYPE html>
    <html>
    <head>
        <title>@ViewBag.Title</title>
        @RenderSection("Header")
    </head>
    <body>
        @RenderBody()
    </body>
    </html>

     Index.cshtml 

    @{
        ViewBag.Title = "Index";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    @section Header{
        <link href="@Url.Content("~/Scripts/uploadify-v3.1/uploadify.css")" rel="stylesheet" type="text/css" />
        <script src="@Url.Content("~/Scripts/jquery-1.8.1.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/uploadify-v3.1/jquery.uploadify-3.1.min.js")" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $('#file_upload').uploadify({
                    'swf'        : '@Url.Content("~/Scripts/uploadify-v3.1/uploadify.swf")',
                    'uploader'   : '/Home/Upload'
                });
            });
        </script>
        <style type="text/css">
            body
            {
                font-size: 12px;
            }
            .tip
            {
                height: 20px;
                border-bottom: 1px solid #CCC;
                margin-bottom: 10px;
            }
        </style>
    }
    <div class="tip">

    2.@{Html.RenderAction("Action", "Controller");}

     @{Html.RenderAction("GenreNavigationMenu", "System");} 

    1).Html.RenderAction()方法往往需要和对应的[ChildActionOnly]属性action方法以及对应的局部chtml模板配合使用,在action方法中常使用return PartialView()方法,通常都被用来显示一个功能相对独立的“块”,比如说显示菜单或者导航条.
    2).允许我们在chtml中可以直接调用某一个Action,并把返回的结果直接显示在当前调用的View中。
    3).return PartialView("TagCloud", tagData);//TagCloud是一个简单的PartialView文件而已

    3.@Html.Partial("_TopNavbar")

    用于在_Layout.cshtml中组装静态模板页面块

    4.@{ Html.RenderPartial(...); }  

    参考

  • 相关阅读:
    冲刺五
    ubuntu安装utorrent
    struts2中properties属性
    Hadoop下的word count程序
    导入svn项目时eclipse崩溃
    Struts2 中jsp直接跳转到action
    用eclipse开发hadoop程序
    ubuntu下安装java
    【橙色警报】最新盗qq号方式,连我这个老鸟都一不小心被骗了
    在ubuntu上安装hadoop(书和官方文档结合的)
  • 原文地址:https://www.cnblogs.com/zhuji/p/7761901.html
Copyright © 2011-2022 走看看