代码之家  ›  专栏  ›  技术社区  ›  yamspog

与mvc.net局部视图,如何访问分配给模板的模型

  •  1
  • yamspog  · 技术社区  · 15 年前

    我有以下定义的部分观点。

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<whoozit.Models.PictureModel>>" %>
    

    如何访问已分配给视图的数据?

    1 回复  |  直到 15 年前
        1
  •  0
  •   Forgotten Semicolon adrianm    15 年前

    你可以这样做:

    <% foreach (whoozit.Models.PictureModel picture in Model)
       { %>
        <%: picture.property1 %><br />
        <%: picture.property2 %><br />
        etc...
    <% } %>