RenderPartialExtensions.RenderPartial Method (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.

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

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Sub RenderPartial ( _
    htmlHelper As HtmlHelper, _
    partialViewName As String, _
    model As Object, _
    viewData As ViewDataDictionary _
)
'Usage
Dim htmlHelper As HtmlHelper
Dim partialViewName As String
Dim model As Object
Dim viewData As ViewDataDictionary

htmlHelper.RenderPartial(partialViewName, _
    model, viewData)
public static void RenderPartial(
    this HtmlHelper htmlHelper,
    string partialViewName,
    Object model,
    ViewDataDictionary viewData
)
[ExtensionAttribute]
public:
static void RenderPartial(
    HtmlHelper^ htmlHelper, 
    String^ partialViewName, 
    Object^ model, 
    ViewDataDictionary^ viewData
)
public static function RenderPartial(
    htmlHelper : HtmlHelper, 
    partialViewName : String, 
    model : Object, 
    viewData : ViewDataDictionary
)

Parameters

  • partialViewName
    Type: System.String
    The name of the partial view.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type HtmlHelper. When you use instance method syntax to call this method, omit the first parameter. For more information, see b8020aae-374d-46a9-bcb7-8cc2390b93b6 or 175ce3ff-9bbf-4e64-8421-faeb81a0bb51.

Remarks

The RenderPartial method renders an ASP.NET user control (.ascx file) as a partial view.

When a partial view is instantiated, it gets its own copy of the ViewDataDictionary object that is available to the parent view. Therefore, the partial view has access to the data of the parent view. However, if the partial view updates the data, those updates affect only the partial view's ViewData object. The parent view's data is not changed.

See Also

Reference

RenderPartialExtensions Class

RenderPartial Overload

System.Web.Mvc.Html Namespace