Other pages do not see the layout page - html

I am working .netcore project.Admin Areas other pages do not see the layout page.I know how it works. I have also done what happened on many sites but it has not been resolved.viewstart's page code:
#{
Layout = "_Layout";
}
Dosya düzeninin fotoğrafı:

Just change Layout to the following url which is the layout.cshtml in Admin area:
#{
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

Related

#RenderSection Equivalent in Blazor?

Razor pages have a mechanism where you can reference named sections in your layout, and then specify them in your pages that use that layout. For example, if your Layout (_Layout.cshtml) looks like this:
#using...
...
<!DOCTYPE html>
...
<body>
...
#RenderSection("modals", required: false)
...
and then in your dashboard page, for example, you'd have:
<div>
...
</div>
...
...
#section modals
{
<div class="modal-container>...</div>
<div class="modal-container>...</div>
}
that would inject the contents of #section modals... into the place in the layout where #RenderSection("modals") is.
How can this be done in Blazor?
Unfortunately, no such feature is currently supported in Blazor. Blazor team and the community have been discussing the necessity of this feature over a year now, but for no avail. Read here about Sections in Blazor.
However, if you're looking for a 'temporary solution', you may read a comment by SteveAndeson about how to pass parameter values from a Blazor component page to its layout. I know that you're looking for a way to render the #Body plus #EndBody, but the principal remain the same: You have to create a layout component instead of the default layout
Hope this helps...
I have created a component to get something similar to sections:
https://github.com/inspgadget/BlazorSections

Orchard CMS: How to display a Layout Part in a view?

I'm trying to specify a different Query Layout for a query that returns several pages and completely take over the rendering of the list following this excellent guide: http://www.ideliverable.com/blog/ways-to-render-lists-of-things
I have the basic implementation setup and know it to be working by using the following simple code for the rendering:
#using Orchard.ContentManagement
#using Orchard.Core.Title.Models
#using Orchard.Layouts.Models
#{
var webPages = ((IEnumerable<ContentItem>)Model.ContentItems).ToList();
}
#foreach (var wp in webPages)
{
var titlePart = wp.As<TitlePart>();
var wpTitle = titlePart.Title;
<p>#T("{0} Title is ", wpTitle)</p>
}
Problem:
However, when attempting to include the Layout of each page, I can't seem to work out how? Using the code below, only the text 'Orchard.Layouts.Models.LayoutPart' is rendered erroneously in the HTML.
var layoutPart = wp.As<LayoutPart>();
#Display(layoutPart)
Therefore, I'm assuming the LayoutPart is different to other common Parts in Orchard, because I have also tested many other parts which all successfully render, except Layouts (I'm thinking the LayoutPart has to be constructed somehow before being displayed, but that is clutching at straws)?
So how does one go about such?
Funnily enough, you're basically right. Layouts have to built before displaying:
#Display(BuildDisplay(layoutPart, "#display type#")) //display type: Summary / Detail

Edit complete HTML of page in Drupal

We have our site running on Drupal. Now I have 2 landingpages: pages without menu's and a bit different in layout as the others. I want to edit the complete HTML of the pages in the Drupal-interface, so marketeers can easily add HTML-snippets (for testing etc), without using a developer.
How could I create an empty header and footer, and let the complete HTML be the content?
You could create a specific node type, and then use this function in your template.php :
<?php
function theme_preprocess_page(&$variables)
{
if (isset($variables['node']->type))
{
$nodetype = $variables['node']->type;
$variables['theme_hook_suggestions'][] = 'page__' . $nodetype;
}
}
It will allows you to create templates for pages (Drupal is only offering this possibility for the page content) based on node types using page--node-type.tpl.php, so that you'll be able to customize the entire page html instead of just the content.

Servicestack Razor, setting Layout to Null

Using ServiceStack.Razor and having a slight issue.
I have a default _Layout.cshtml page that is my base layout, but for some pages, I don't want a layout, I just want to a full html page with no templating, similar to how setting the Layout to null in ASP.NET MVC would work.
I cannot figure out how to do this, and can't find anything in the documentation (not saying it's not there, just can't find it).
Things I've tried:
Setting the Layout property to null on the actual view page:
#{
Layout = null;
}
Returning a null template from the actual service:
return HttpResult(dto) { Template = null; };
Moving my view page out of the Views folder (this just took it back to the default ServiceStack view page)
Any help greatly appreciated.
Thanks, and sorry if I missed something simple
Layout=null indicates no Layout was specified, so will use the default _Layout.cshtml.
You can use an empty string "" for no Layout, e.g:
#{
Layout = "";
}
Otherwise if preferred, create an "Empty" layout e.g: /Views/Shared/Empty.cshtml containing just:
#RenderBody()

Layout page's code not being sent to content pages

I have a _SiteLayout.cshtml file which structures the site and has some C# code on it. How do I send the _SiteLayout's C# code to all of its subpages? I am using WebPages Razor 2.
Thank you in advance.
There are two methods for implementing a layout page:
use the Layout command in the code section of every page, as outlined in Creating a Consistent Layout in ASP.NET Web Pages (Razor) Sites
or initialize the same layout page for all files in a single folder using the _PageStart.cshtml file(Customizing Site-Wide Behavior for ASP.NET Web Pages (Razor) Sites).
In the latter case you could disable the layout page for a single page using Layout = null in the code section.
Edit
If you want to pass data from a master page to a partial page, you must use the RenderPage() method instead of the RenderBody() method, but the structure of your site fully changes.
If, by example, you want to create a master page that extracts data from a table and passes them to a partial page that can change, your master page could be something like:
#{
var db = Database.Open("Northwind");
var data = db.Query(#"SELECT [Product Id], [Product Name],
[English Name] FROM Products ");
var page = "Partial.cshtml";
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
#RenderPage(page, new {gridData = data})
</body>
</html>
The code in Partial.cshtml takes data from the Page.gridData variable and displays them in a WebGrid:
#{
var grid = new WebGrid(Page.gridData);
}
<div>#grid.GetHtml()</div>