Share via


RenderPartialExtensions Class

Provides support for rendering a partial view.

Inheritance Hierarchy

System.Object
  System.Web.Mvc.Html.RenderPartialExtensions

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

Syntax

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

Methods

  Name Description
Public methodStatic member RenderPartial(HtmlHelper, String) Renders the specified partial view by using the specified HMTL helper.
Public methodStatic member RenderPartial(HtmlHelper, String, Object) Renders the specified partial view, passing it a copy of the current ViewDataDictionary object, but with the Model property set to the specified model.
Public methodStatic member RenderPartial(HtmlHelper, String, ViewDataDictionary) Renders the specified partial view, replacing its ViewData property with the specified ViewDataDictionary object.
Public methodStatic member RenderPartial(HtmlHelper, String, Object, ViewDataDictionary) Renders the specified partial view, replacing the partial view's ViewData property with the specified ViewDataDictionary object and setting the Model property of the view data to the specified model.

Top

Remarks

The RenderPartialExtensions class contains methods that extend the HtmlHelper class. The RenderPartial method renders an ASP.NET user control (.ascx file) as a partial view.

Examples

The following example shows how to create a partial view as a user control (.ascx file). The control displays the date and time strings that are passed in the ViewDataDictionary object. The control also calls the ActionLink helper method to refresh the date and time.

In the following example, the Index action method initializes the date and time strings and renders the Index view.

The following Index view shows how to use the RenderPartial helper method to display the partial view within its parent view. Unlike other HTML helper methods, a call to the RenderPartial method is enclosed in <% %> characters instead of <%= %> characters. This is because the RenderPartial method renders directly to the output stream. In contrast, most other helper methods return a string.

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