Skip to content

Ability to read page title in a .razor file (e.g. layout.razor) #38686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
conficient opened this issue Nov 29, 2021 · 1 comment
Closed

Ability to read page title in a .razor file (e.g. layout.razor) #38686

conficient opened this issue Nov 29, 2021 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@conficient
Copy link
Contributor

With .NET 6 we are able to set a browser page title using the <PageTitle> component in a .razor file, which is rendered in the <head> using the <HeadOutlet> component. All good.

I wished to use the page title in a <h1> tag that is in the MainLayout.razor template - however I could not see a way to obtain this from the way <HeadOutlet> works?

I was able to make a work-around by creating a cascading PageManager class, and setting the page title via this, but it seems it should be easier?

@pranavkm pranavkm added the area-blazor Includes: Blazor, Razor Components label Nov 29, 2021
@mkArtakMSFT
Copy link
Member

Thanks for contacting us.
There is no better way to do this yet, so what you've got to is a fine solution. We plan to improve this in the future as part of the #28182

@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Nov 29, 2021
@ghost ghost added the Status: Resolved label Nov 29, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Dec 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants