Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include a razor page to another razor page?

I'd like to know how to include another razor page in running razor view just as PHP's "include" term. It can be considered as partial classes. Half of work is done at a.cshtml and the other half of works are done at b.cshtml. But in reality two of them are built as one razor page.

Any ideas will be appreciated...

like image 222
Mesut Avatar asked Oct 13 '12 17:10

Mesut


People also ask

How do I add a page to Razor pages?

You'll need to right-click on your project in Solution Explorer, select Add Folder and, when the Add Folder dialog is displayed, add a Folder called Pages. Once that Pages folder is created, you can right-click on it and select Add | New Item to display the Add New Item dialog.

How do I navigate from one Razor to another page?

you can do it in the client side, in javascript. Also create an anchor a set the asp-controller and asp-action and there you redirect. Or create an anchor a and hard code the path.

Can I use Razor components in Razor pages?

Razor components can easily be used within a Razor Pages application. UI and processing code can be partitioned within the same file, or separated out into different files, which can help with unit testing.


1 Answers

You can use Partial Views in MVC.

Try RenderAction or RenderPartial methods to render another view or partial view in a current view.

More Reference :

RenderAction RenderPartial

Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction

like image 67
Kundan Singh Chouhan Avatar answered Sep 20 '22 05:09

Kundan Singh Chouhan