Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, can you display the page title from a Partial-page. I would like to set the page title from the Partial-page.
I have the following code within my master layout
@Umbraco.Field("title", altFieldAlias: "pageName")
And within my Partial-page I have the following code
if (ApplyingChk == true){ <title> title 1 </title>} else { <title> title 2 </title>}
But I keep getting the page title instead of the Partial-page title. I hope this makes sense?
Hi Tom,
in the way you are describing you now set the title tag twice, once in the master page and once in the partial view correct?
Where do you call the partial view, is it on the master page?
If so then remove the @Umbraco.Field("title", altFieldAlias: "pageName") and place the call to your partial view for rendering the title here.
Then in your partial view you can set the correct title tag based on your conditions.
Another solution could be using a @helper class on your master page for rendering the title tag, then you won't need to call a partial view.
Hope this helps
/Michaël
Hi Michael, I call the the partial view from a template like so;
@{ Html.RenderAction("RenderApplicantDetails", "Applicant");}
I have removed the @Umbraco.Field("title", altFieldAlias: "pageName") from the master page and placed it into the template page, but I keep getting the page title.
How do I render the title that's on the partial-page?
can you share the code from your template / partial view?
Hi Michael, I think I found the answer by placing the following code into my partial page
@{ ViewBag.Title = "About Us From The Partial View"; }
<script type="text/javascript"> document.title = "@ViewBag.Title";
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to display the page title from a partial page
Hi, can you display the page title from a Partial-page. I would like to set the page title from the Partial-page.
I have the following code within my master layout
And within my Partial-page I have the following code
But I keep getting the page title instead of the Partial-page title. I hope this makes sense?
Hi Tom,
in the way you are describing you now set the title tag twice, once in the master page and once in the partial view correct?
Where do you call the partial view, is it on the master page?
If so then remove the
@Umbraco.Field("title", altFieldAlias: "pageName")
and place the call to your partial view for rendering the title here.Then in your partial view you can set the correct title tag based on your conditions.
Another solution could be using a @helper class on your master page for rendering the title tag, then you won't need to call a partial view.
Hope this helps
/Michaël
Hi Michael, I call the the partial view from a template like so;
I have removed the @Umbraco.Field("title", altFieldAlias: "pageName") from the master page and placed it into the template page, but I keep getting the page title.
How do I render the title that's on the partial-page?
Hi Tom,
can you share the code from your template / partial view?
/Michaël
Hi Michael, I think I found the answer by placing the following code into my partial page
@{ ViewBag.Title = "About Us From The Partial View"; }
is working on a reply...