A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.umbraco.com/umbraco-cms/13.latest/fundamentals/design/partial-views below:

Partial Views | Umbraco CMS

Partial Views | Umbraco CMS
  1. Fundamentals
  2. Design
Partial Views

Information on working with partial views in Umbraco

A Partial View (.cshtml file) is a regular view that can be used multiple times throughout your site. A Partial View is used to break up large markup files into smaller components such as header, footer, navigation menu, etc. It helps to reduce the duplication of code. A partial view renders a view within the parent view.

Partial Views in the Backoffice

You can create and edit partial views in the Partial Views folder from the Settings section of the Backoffice.

Creating a new partial view

In the Create menu, there are three options available:

To create a partial view, go to the Settings section in the Umbraco backoffice and right-click the Partial Views folder. Choose Create. Select New empty partial view and enter a partial view name and click the Save button. You will now see the partial view markup in the backoffice editor.

Created partial view

By default, the partial view is saved in the Views/Partials folder in the solution.

Creating a Partial View from Snippet

To create a partial view from the snippet, go to the Settings section in the Umbraco backoffice and right-click the Partial Views folder. Choose Create. Select New empty partial view from snippet. Select the snippet you want to create a partial view for and enter a partial view name. The code snippet you selected is displayed in the backoffice editor. Click the Save button.

Created partial view from snippet

By default, the partial view is saved in the Views/Partials folder in the solution. Umbraco provides the following partial view snippets:

To create a folder, go to the Settings section in the Umbraco backoffice and right-click the Partial Views folder. Choose Create. Select Folder. Enter a folder name and click the Create button.

Created folder

To render the created partial view into any template, use any of these helper methods: @Html.PartialAsync, @Html.Partial(), or @Html.RenderPartial()

@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.HomePage>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
	Layout = null;
}

@await Html.PartialAsync("Login")

@Html.Partial("Login")

@{
 Html.RenderPartial("Login");   
}
Getting started with Umbraco: Partial Views

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4