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>

partialview 用法的更多相关文章

  1. ASP.NET MVC PartialView用法

    子页面AreaSelect.cshtml页面的Controller代码: public ActionResult AreaSelect() { return PartialView(); } 父页面前 ...

  2. EF5+MVC4系列(12) 在主视图中直接用RenderAction调用子Action,并返回视图(Return View)或者分部视图(Return PartialView); 从主Action传值到子Action使用TempData传值;TempData高级用法

    结论: ViewData 适用于 在一次请求中 传递数据  . 比如我们从 主Action 到 主视图, 然后在 主视图中  用 RenderAction 请求子Action的时候,就是算作 一次请求 ...

  3. ASP.NET MVC Ajax.ActionLink 简单用法

    ASP.NET MVC 项目中,如何使用类似于 iframe 的效果呢?或者说 Ajax 局部刷新,比如下面操作: 我们想要的效果是,点击 About 链接,页面不刷新(地址栏不变),然后下面的内容进 ...

  4. MVC5 + EF6 + Bootstrap3 (14) 分部视图PartialView

    Slark.NET-博客园 http://www.cnblogs.com/slark/p/mvc5-ef6-bs3-get-started-partialview.html 系列教程:MVC5 + E ...

  5. Partial RenderPartial Action RenderAction 区别和用法

    区别: 1.Partial 与 RenderPartial 两个方法性质基本一样,只是把一个静态用户控件给嵌入进来. 2.Partial 回传一堆html代码,直接写进到页面上@Html.Partia ...

  6. Asp.Net MVC3.0 Partial RenderPartial Action RenderAction 区别和用法

    本人写的博文不多,专业知识不强,以下纯属于个人笔记.如有不对,还请各路大拿,拍砖指导,谢谢! 区别: 1.Partial 与 RenderPartial 两个方法性质基本一样,只是把一个静态用户控件给 ...

  7. Html.Partial和Html. RenderPartial用法

    Html.Partial和Html. RenderPartial用法 Html.partial和RenderPartial的用法与区别Html.partial和RenderPartial都是输出htm ...

  8. asp.net mvc Html.BeginForm()及Html.Action用法

    Html.BeginForm    Add:操作方法的名称,Activities:控制器的名称,FormMethod.Post:定义from的method的值,,new { id = "fo ...

  9. MVC |分部视图 PartialView()

    介绍如何定义 其实它和普通视图没有多大区别,只是创建分部视图的时候视图里没有任何内容,你需要什么标签你自己加.第二就是分部视图不会执行_ViewStart.cshtml中的内容) 控制器 Partia ...

随机推荐

  1. [2/100] MySQL在Windows下安装及一些问题

    mysql 是RDBMS(关系型数据库) 其他: redis 一般做缓存用 mangoDB 一般做爬虫用 国内镜像下载地址: http://mirrors.sohu.com/mysql/MySQL-8 ...

  2. Codeforces Round #616 (Div. 2) D

    莫队的模板 struct node{ int l,r,id; }q[maxn]; int cmp(node a,node b) { ) ? a.r < b.r : a.r > b.r); ...

  3. QWidget: “Must construct a QApplication before a QWidget”

    最近在做一个关于Qt的项目,在debug版本中没有任何问题,所以就想看看在Release版本下的运行情况,结果在开始运行时,出现如下图1-1所示的错误.在网上搜索答案,大多数是关于QWidget: M ...

  4. laravel 左联报错问题

  5. win10的guard占内存过高

    转自:https://zhidao.baidu.com/question/1180883495203481459.html win10的guard占内存过高,

  6. PAT T1013 Image Segmentation

    krustral算法加并查集,按题给要求维护并查集~ #include<bits/stdc++.h> using namespace std; ; const int inf=1e9; i ...

  7. CSS布局的三种机制

    浮动元素之间没有缝隙,这和行内块还是不一样的,有点区别的! 2) 浮动元素与兄弟盒子之间的关系 注意:解决浮动的四种办法,后三种都是针对浮动元素的父元素的.

  8. matplotlib常见操作

    import osimport numpy as npfrom PIL import Imageimport matplotlib.pyplot as plt img = Image.open(os. ...

  9. HIHOcoder编程总结

    [Offer收割]编程练习赛44 对于第一题题目1 : 扫雷游戏,首先要想清楚思路,虽然是暴力算法,但是这八个方向要自己把坐标写正确,不要慌乱,自己写的时候就写错了一个,第二个就是判断的时候,j + ...

  10. 转:Entity Framework 5.0 Code First全面学习

    Code First 约定 借助 CodeFirst,可通过使用 C# 或Visual Basic .NET 类来描述模型.模型的基本形状可通过约定来检测.约定是规则集,用于在使用 Code Firs ...