Skip to content

Question: In Blazor Wasm, is it possible to capture the generated html from a Blazor component? #41508

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
1 task done
roysurles opened this issue May 4, 2022 · 3 comments
Closed
1 task done
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@roysurles
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Use case: capture the generated html from a Blazor component and send it to a pdf.

Describe the solution you'd like

In Blazor Wasm, capture the generated html from a Blazor component

Additional context

No response

@javiercn
Copy link
Member

javiercn commented May 4, 2022

@roysurles thanks for contacting us.

It's not possible as the components don't generate HTML, they generate a sequence of instructions that get transmitted to the browser where JavaScript turns that into HTML.

On webassembly you could render the component on to the page and then use JS interop to capture/retrieve the serialized DOM text as a string.

If you were on a server you could "prerender" the component to obtain the HTML.

@javiercn javiercn added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. labels May 4, 2022
@ghost ghost added the Status: Resolved label May 4, 2022
@javiercn
Copy link
Member

javiercn commented May 4, 2022

We do have an issue to support rendering components in isolation, if you are interested on such functionality I would suggest you upvote the issue here

@ghost
Copy link

ghost commented May 5, 2022

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed May 5, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants