Provides support for rendering a partial view.
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
|RenderPartial(HtmlHelper, String)||Renders the specified partial view by using the specified HMTL helper.|
|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.|
|RenderPartial(HtmlHelper, String, ViewDataDictionary)||Renders the specified partial view, replacing its ViewData property with the specified ViewDataDictionary object.|
|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.|
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.