Child Action

Control


[ChildActionOnly]      //只能用于Child Action
public ActionResult Time() {
return PartialView(DateTime.Now);
}

 

View


@model DateTime
<p>The time is: @Model.ToShortTimeString()</p>

 

 

@Html.Action("Time")

 

与分布视图不同的是,Child Action可以在Control中提供需要的数据。

posted @ 2014-07-06 11:35  秋意了了  阅读(272)  评论(1编辑  收藏  举报