• 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>

  • 相关阅读:
    toj4119HDFS
    hdu2952Counting Sheep
    hdu2393Higher Math
    hdu2317Nasty Hacks
    hdu2309ICPC Score Totalizer Software
    hdu2304Electrical Outlets
    hdu2399GPA
    一、 软件测试概述
    JQuery选择器大全
    如何避免jQuery库和其他库的冲突
  • 原文地址:https://www.cnblogs.com/sxjljj/p/8537614.html
Copyright © 2020-2023  润新知