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中提供需要的数据。
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中提供需要的数据。