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...
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With