zoukankan      html  css  js  c++  java
  • partialview 用法

    using  MvcApplication1.Models;

    @model MvcApplication1.Models.UserInfoModel

    @{     ViewBag.Title = "Index";     Layout = "~/Views/Shared/Admin.cshtml"; }

    <h2>Index</h2>

    @*@Html.Partial("UserListPartial")

    @Html.Partial("UserListPartial",1)*@

    @Html.Partial("UserListPartial",@Model.UserList) @*

    @Html.RenderPartial("UserListPartial")*@

    @{         //用html.Partial调用的后台代码         

        //public ActionResult Index()     

        //{         //    TestMVC.Msg.UserDB userdb = new TestMVC.Msg.UserDB(ConfigurationManager.ConnectionStrings["TestMvcConnectionString"].ToString());      

       //    UserInfoModel userInfoModel = new UserInfoModel();

            //    userInfoModel.UserList = new List<Models.UserDetail>();   

          //    DataSet ds = userdb.GetAll();    

         //    if (ds != null && ds.Tables[0].Rows.Count > 0)       

      //    {         //        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)        

    //        {         //            Models.UserDetail userDetail = new Models.UserDetail();        

    //            userDetail.UserID = ds.Tables[0].Rows[i]["UserID"].ToString();        

    //            userDetail.UserName = ds.Tables[0].Rows[i]["UserName"].ToString();        

    //            userDetail.Sex = ds.Tables[0].Rows[i]["Sex"].ToString();        

    //            userDetail.BirthDay = ds.Tables[0].Rows[i]["BirthDay"].ToString();        

    //            userDetail.Emalil = ds.Tables[0].Rows[i]["Emalil"].ToString();        

    //            userDetail.Addr1 = ds.Tables[0].Rows[i]["Addr1"].ToString();       

      //            userDetail.Addr2 = ds.Tables[0].Rows[i]["Addr2"].ToString();        

    //            userInfoModel.UserList.Add(userDetail);         //        }

        //    }

      //    return View(userInfoModel);         //}

            //public ActionResult UserListPartial()  

           //{         //    return PartialView();         //}

       }

    @*    服务器端代码 ,用action的调用方法

    @Html.Action("NonCameraImagePartialView")

    @{Html.RenderAction("NonCameraImagePartialView", new { notIntNo =1 });}

       public ActionResult NonCameraImagePartialView(int notIntNo)  

           {             NonCameraImageModel model = new NonCameraImageModel();     

              model.NotIntNo = notIntNo;       

              model.ImageUrls = GetNonCameraImage(notIntNo);

              return PartialView("NonCameraImagePartialView",model);       

      }

    *@

    @*UserListPartial.cshtml 视图*@

    @*@model int

    @model MvcApplication1.Models.UserDetail*@

    @model IEnumerable<MvcApplication1.Models.UserDetail>

    <h2>partialveiw</h2>

    @*<h2>@Model</h2>*@

    <table>  

       @foreach(var item in Model)  

       {                 <tr>            

                     <td>@item.UserID</td>            

                    <td>@item.UserName</td>       

                    </tr>    

          } </table>

  • 相关阅读:
    黑马程序员:3分钟带你读懂C/C++学习路线
    大学毕业的你,满腔洪荒之力却找不到出口?
    从零基础到精通的前端学习路线
    Python学习笔记(2)——Python的函数、模块、包和库
    Python学习笔记(1)——Python的概述(Python的环境、变量、数据类型、基本运算)
    MATLAB优化——减少for的使用
    初识Python(windows)——下载、安装、使用
    高维数据稀疏表示-什么是字典学习(过完备词典)
    用1天快速上手org-mode(windows系统)
    零基础数据挖掘学习清单
  • 原文地址:https://www.cnblogs.com/sxjljj/p/8537614.html
Copyright © 2011-2022 走看看