共用方式為


ChildActionExtensions Class

Represents support for calling child action methods and rendering the result inline in a parent view.

Inheritance Hierarchy

System.Object
  System.Web.Mvc.Html.ChildActionExtensions

Namespace:  System.Web.Mvc.Html
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
<ExtensionAttribute> _
Public NotInheritable Class ChildActionExtensions
public static class ChildActionExtensions
[ExtensionAttribute]
public ref class ChildActionExtensions abstract sealed

Methods

  Name Description
Public methodStatic member Action(HtmlHelper, String) Invokes the specified child action method and returns the result as an HTML string.
Public methodStatic member Action(HtmlHelper, String, Object) Invokes the specified child action method with the specified parameters and returns the result as an HTML string.
Public methodStatic member Action(HtmlHelper, String, String) Invokes the specified child action method using the specified controller name and returns the result as an HTML string.
Public methodStatic member Action(HtmlHelper, String, RouteValueDictionary) Invokes the specified child action method using the specified parameters and returns the result as an HTML string.
Public methodStatic member Action(HtmlHelper, String, String, Object) Invokes the specified child action method using the specified parameters and controller name and returns the result as an HTML string.
Public methodStatic member Action(HtmlHelper, String, String, RouteValueDictionary) Invokes the specified child action method using the specified parameters and controller name and returns the result as an HTML string.
Public methodStatic member RenderAction(HtmlHelper, String) Invokes the specified child action method and renders the result inline in the parent view.
Public methodStatic member RenderAction(HtmlHelper, String, Object) Invokes the specified child action method using the specified parameters and renders the result inline in the parent view.
Public methodStatic member RenderAction(HtmlHelper, String, String) Invokes the specified child action method using the specified controller name and renders the result inline in the parent view.
Public methodStatic member RenderAction(HtmlHelper, String, RouteValueDictionary) Invokes the specified child action method using the specified parameters and renders the result inline in the parent view.
Public methodStatic member RenderAction(HtmlHelper, String, String, Object) Invokes the specified child action method using the specified parameters and controller name and renders the result inline in the parent view.
Public methodStatic member RenderAction(HtmlHelper, String, String, RouteValueDictionary) Invokes the specified child action method using the specified parameters and controller name and renders the result inline in the parent view.

Top

Remarks

A child action method renders part of a view instead of the whole view. To call a child action, use either the Action method, which returns an HTML string, or the RenderAction method, which renders the action results inline.

A call to Action or RenderAction uses the existing HTTP context, so the request data is relative to the original request (including the raw URL of the request). This means that from the rendered action you can bind to data from the original request (including form values, query string values, route values, and so on). This also means that all relative URLs that are returned by the child action's view will be relative to the parent (root) action. The HTTP method of the request will be the method of the parent (root) request.

The HandleErrorAttribute attribute on a child action method is ignored if an exception occurs in the child action itself. Therefore, a child action should handle its own exceptions. If a child action has an AuthorizeAttribute attribute applied, the attribute will execute and return an HTTP Unauthorized 401 status code.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Web.Mvc.Html Namespace

Other Resources

Creating an ASP.NET MVC View by Calling Multiple Actions