RenderPartial Method (HtmlHelper, String, Object, ViewDataDictionary)

RenderPartialExtensions.RenderPartial Method (HtmlHelper, String, Object, ViewDataDictionary)

Visual Studio 2010

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)

public static void RenderPartial(
	this HtmlHelper htmlHelper,
	string partialViewName,
	Object model,
	ViewDataDictionary viewData
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper
The HTML helper.
partialViewName
Type: System.String
The name of the partial view.
model
Type: System.Object
The model for the partial view.
viewData
Type: System.Web.Mvc.ViewDataDictionary
The view data for 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 Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

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.

Community Additions

ADD
Show:
© 2016 Microsoft