Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling RenderPartial from an Area

This is my folder structure

alt text

I wan to call a partialview from my view on my area

like image 775
Aivan Monceller Avatar asked Jan 15 '11 16:01

Aivan Monceller


People also ask

How to load partial view?

To create a partial view, right click on the Shared folder -> click Add -> click View.. to open the Add View popup, as shown below. You can create a partial view in any View folder. However, it is recommended to create all your partial views in the Shared folder so that they can be used in multiple views.

What is mean by partial view?

A partial view is a Razor markup file ( . cshtml ) without an @page directive that renders HTML output within another markup file's rendered output. The term partial view is used when developing either an MVC app, where markup files are called views, or a Razor Pages app, where markup files are called pages.

How to use partial view in. net core?

cshtml before the rendering and also, partial view rendered within another view. Partial view is normally rendered in the main views using @Html. Partial() method. Partial view passes the name of the partial and also can pass a model data which is basically optional.

What is difference between render partial and partial?

The primary difference between the two methods is that Partial generates the HTML from the View and returns it to the View to be incorporated into the page. RenderPartial, on the other hand, doesn't return anything and, instead, adds its HTML directly to the Response object's output.


1 Answers

You could specify the full location of the view when rendering it:

<% Html.RenderPartial("~/Areas/User/Views/SomeController/Foo.ascx"); %>

UPDATE:

And in order to call a partial from the Shared folder:

<% Html.RenderPartial("~/Views/Shared/Foo.ascx"); %>
like image 99
Darin Dimitrov Avatar answered Sep 30 '22 02:09

Darin Dimitrov