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

你可能感兴趣的:(action)