I have a C# MVC application with a pretty-much standard Bootstrap display.
As usual the Navbar is provided by Shared\_Layout.cshtml.
However one of my pages will only be used for generating a PDF using an HTML/PDF converter, so I don't want the Navbar to appear.
Is there a way to prevent this for specific pages?
I realised all I had to do was to add a querystring parameter that I can check for in _Layout.cshtml, i.e.:
<body>
#if(Request.QueryString["noheader"] == null)
{
<div class="no-print navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
...
Related
I have a <form> where I am using Vue.js and Quasar, and submits in as a HTML form in asp .net core 3.1
The problem is when I am using Quasar Uploader (https://quasar.dev/vue-components/uploader).
The functionality works fine, but when I submit the form (post i C# and .net core).
I cant get the the file in the controller.
As you can see from this example: https://codepen.io/cbrown___/pen/GRZwpxw
When the Uploader is rendered it does not have the attribute name. From the example above you have this input:
<input tabindex="-1" type="file" title="" class="q-uploader__input overflow-hidden absolute-full">.
I guess that is why I cant get it from my Controller. How can I solve this when I am using .net Core 3.1 to submit this form?
And I see no good solutinos in letting people upload files through my API before the record is created.
Is it a option here I do not see?
EDIT:
The <input> is on the plus-icon. So by using inspect elements you should be able to see that no name occurs.
EXAMPLE CODE:
HTML
<div id="q-app">
<div class="q-pa-md">
<div class="q-gutter-sm row items-start">
<q-uploader
url="http://localhost:4444/upload"
style="max-width: 300px"
></q-uploader>
<q-uploader
url="http://localhost:4444/upload"
color="teal"
flat
bordered
style="max-width: 300px"
></q-uploader>
<q-uploader
url="http://localhost:4444/upload"
label="Upload files"
color="purple"
square
flat
bordered
style="max-width: 300px"
></q-uploader>
<q-uploader
url="http://localhost:4444/upload"
label="No thumbnails"
color="amber"
text-color="black"
no-thumbnails
style="max-width: 300px"
></q-uploader>
</div>
</div>
</div>
JS:
new Vue({
el: '#q-app'
})
If any body else need this I ended up with using this:
:name="'file_description[' + index + ']'"
That way each one got one name...and from another array I knew how many file_description it would be.
my html code:
<div class="header"></div>
<div class="tiles"></div>
<div class="list"></div>
<div class="footer"></div>
changed to:
<div class="header"></div>
<div class="content">
<div class="tiles"></div>
<div class="list"></div>
</div>
<div class="footer"></div>
I made a content div around tiles and list.
My problem is by doing that my html won't update in my browser.
and yes i already cleared my browser cache, I disabled caching in devtool.
I added no cache meta tag. I rebuild my solution, clean solution no luck. Whatever code i add or delete nothing happens. My css is updated not the html.
I tested it by just deleting my content and when I run my project I still had every content on my browser. What else can I do to fix this?
I am using Asp.net MVC. In the layout page I want to store footer in a file and call it using RenderPage. It looks that everything is OK but when I run the website I get this error:
this is the file tree for project
_Footer.cshtml is located in Shared Folder
content for _Footer.cshtml
<div id="copyrights">
<div class="container clearfix">
<div class="col_half">
</div>
</div>
</div><!-- #copyrights end -->
In ASP.NET MVC you can use
#Html.Partial("_Footer") or #{Html.RenderPartial("_Footer");}
I've seen a few posts on this topic:
Razor Nested Layouts with Cascading Sections
MVC 3 - Nested layouts - sections don't render in Areas
And it always seems to be problematic. However they are both pretty old so wondering if things have changed.
Basically I have a master layout, and 3 different body templates based on what kind of page it is. For examples sake:
_Layout.cshtml
<html lang="en">
<head>
</head>
<body style="padding: 50px 0;">
<header class="navbar navbar-default navbar-fixed-top" role="banner">
#Html.Partial("_MenuPartial")
</header>
<ol class="breadcrumbs">
#RenderSection("breadcrumbs", true);
</ol>
<section>
#RenderBody();
</section>
<footer class="navbar navbar-default navbar-fixed-bottom">
#Html.Partial("_FooterPartial")
</footer>
#Html.Partial("_ScriptInitPartial")
</body>
</html>
_LayoutForEdit.cshtml
<div class="panel panel-primary">
<div class="panel-body">
<div class="col-lg-2">
<ul class="nav nav-pills nav-stacked">
#RenderSection("tabs", true)
</ul>
</div>
<div class="col-lg-10">
<div class="tab-content">
#RenderBody()
</div>
</div>
</div>
<div class="panel-footer">
<button class="btn btn-primary" data-bind="enable: Entity.isValid, click: save">Save</button>
</div>
</div>
Now this renders fine when called. Almost.
The rendering of sections must be in the child layout it seems. If I try to put the breadcrumbs in the _Layout.cshtml, it will fail because _LayoutForEdit.cshtml never rendered it. How can I fix this?
The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/_LayoutForEdit.cshtml": "breadcrumbs".
I know it's an old question. I thought I'd share this anyway in case anyone else runs into this (like I did).
At the bottom of your child layout, you define a section with the same name as the section in the parent layout. Inside of this section you simply put a #RenderSection, again specifying the same name as before. Once this is in place, you essentially have the child layout "bypass" content from pages, up to its parent layout:
#section breadcrumbs {
#RenderSection("breadcrumbs", true)
}
Not sure if you still need help, but I'll answer anyways.
There RenderSection method takes the following parameters according to the
MSDN Documentation:
public HelperResult RenderSection(
string name,
bool required
)
Parameters
name
Type: System.String
The section to render.
required
Type: System.Boolean
true to specify that the section is required; otherwise, false.
Change the call to:
#RenderSection("breadcrumbs", false);
If the section "required" parameter is false, it will not give an error if that section is not included by a view.
I've created a section for a footer in my asp.net MVC 3 Web Application:
<footer>
#RenderSection("Footer", true)
</footer>
This footer will be the same on every page, so it doesn't make sense for me to define it for each and every view. So, is there any way I can globally declare this footer section for all views? The footer will contain code so as far as I know it's bad practice, if not impossible, to directly define it in the .cshtml file.
Thank you in advance.
I have handled the same scenario by creating a partial view "_Footer" and place it on the "_Layout".
#ViewBag.Title
#Html.Partial("_Header")
<div id="content">
<div id="nav-bar">
#Html.Partial("_Menu")
</div>
<div class="container">
#RenderBody()
</div>
</div>
<div id="footer">
#Html.Partial("_Footer")
</div>
#Html.Partial("_Scripts")
Sure:
<footer>
#if (IsSectionDefined("footer"))
{
#RenderSection("footer")
}
else
{
... put your default footer here
}
</footer>
And in views that you want to override the footer simply define the section.
You can place the footer in your SiteLayout.cshtml. See this article for more information on using layouts with MVC 3.