RenderPartialExtensions.RenderPartial Method

 

Renders the specified partial-view control.

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

Overload List

Name Description
System_CAPS_pubmethodSystem_CAPS_static RenderPartial(HtmlHelper, String)

Renders the specified partial view by using the specified HTML helper.

System_CAPS_pubmethodSystem_CAPS_static 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.

System_CAPS_pubmethodSystem_CAPS_static 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.

System_CAPS_pubmethodSystem_CAPS_static RenderPartial(HtmlHelper, String, ViewDataDictionary)

Renders the specified partial view, replacing its ViewData property with the specified ViewDataDictionary object.

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

RenderPartialExtensions Class
System.Web.Mvc.Html Namespace

Return to top

RenderPartialExtensions.RenderPartial Method (HtmlHelper, String)

Renders the specified partial view by using the specified HTML helper.

Syntax

public static void RenderPartial(
    this HtmlHelper htmlHelper,
    string partialViewName
)
public:
[ExtensionAttribute]
static void RenderPartial(
    HtmlHelper^ htmlHelper,
    String^ partialViewName
)
static member RenderPartial : 
        htmlHelper:HtmlHelper *
        partialViewName:string -> unit
<ExtensionAttribute>
Public Shared Sub RenderPartial (
    htmlHelper As HtmlHelper,
    partialViewName As String
)

Parameters

  • partialViewName
    Type: System.String

    The name of the partial view

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.

Return to top

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

Syntax

public static void RenderPartial(
    this HtmlHelper htmlHelper,
    string partialViewName,
    object model
)
public:
[ExtensionAttribute]
static void RenderPartial(
    HtmlHelper^ htmlHelper,
    String^ partialViewName,
    Object^ model
)
static member RenderPartial : 
        htmlHelper:HtmlHelper *
        partialViewName:string *
        model:Object -> unit
<ExtensionAttribute>
Public Shared Sub RenderPartial (
    htmlHelper As HtmlHelper,
    partialViewName As String,
    model As Object
)

Parameters

  • partialViewName
    Type: System.String

    The name of the partial view.

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.

Return to top

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.

Syntax

public static void RenderPartial(
    this HtmlHelper htmlHelper,
    string partialViewName,
    object model,
    ViewDataDictionary viewData
)
public:
[ExtensionAttribute]
static void RenderPartial(
    HtmlHelper^ htmlHelper,
    String^ partialViewName,
    Object^ model,
    ViewDataDictionary^ viewData
)
static member RenderPartial : 
        htmlHelper:HtmlHelper *
        partialViewName:string *
        model:Object *
        viewData:ViewDataDictionary -> unit
<ExtensionAttribute>
Public Shared Sub RenderPartial (
    htmlHelper As HtmlHelper,
    partialViewName As String,
    model As Object,
    viewData As ViewDataDictionary
)

Parameters

  • partialViewName
    Type: System.String

    The name of the partial view.

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.

Return to top

RenderPartialExtensions.RenderPartial Method (HtmlHelper, String, ViewDataDictionary)

Renders the specified partial view, replacing its ViewData property with the specified ViewDataDictionary object.

Syntax

public static void RenderPartial(
    this HtmlHelper htmlHelper,
    string partialViewName,
    ViewDataDictionary viewData
)
public:
[ExtensionAttribute]
static void RenderPartial(
    HtmlHelper^ htmlHelper,
    String^ partialViewName,
    ViewDataDictionary^ viewData
)
static member RenderPartial : 
        htmlHelper:HtmlHelper *
        partialViewName:string *
        viewData:ViewDataDictionary -> unit
<ExtensionAttribute>
Public Shared Sub RenderPartial (
    htmlHelper As HtmlHelper,
    partialViewName As String,
    viewData As ViewDataDictionary
)

Parameters

  • partialViewName
    Type: System.String

    The name of the partial view.

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.

Return to top