I need to know the way to pull the current HTML "render" from ASP.NET, plus all the data fields that have been modified into their current state by the user using my application. The reason for this is to create a PDF hard copy of the Submitted data. If
I can do this programmatically, I will avoid having to generate the PDF manually which is a rather complex form.
In my application's current state, the user form in HTML looks almost exactly like a paper form. This HTML form displays perfectly, and as plain HTML of the form itself, it renders to PDF perfectly. What this form is missing at this point is the data points
that were edited into the HTML form before the Submit button was pressed.
Is it possible to have a Javascript script that will pull all the HTML and load the appropriate value pairs with all data that currently exists on the page? My PDF also shows the default selections for radio buttons, etc, but what if the user selects something
that moves this selection to another item? Can a javascript script account for that and set the appropriate field?
In a nutshell, what I'm trying to do is upon Submit, collect the state of the page ASP.NET would know it and simply produce the HTML string from the current state instead of have to manually do anything with the page or the PDF I'm trying to create.
Is it possible to have a Javascript script that will pull all the HTML and load the appropriate value pairs with all data that currently exists on the page? My PDF also shows the default selections for radio buttons, etc, but what if the user selects something
that moves this selection to another item? Can a javascript script account for that and set the appropriate field?
You can use document.documentElement.innerHTML to get all the html text after the page is loaded.
And use Javascript script to get the value of each element through the selector. When the user modifies the value of the relevant element, you could use some events like onchange() to modify the html text content accordingly.
When you submit to the server, you can still get the form data in the request, and then get the value of these elements values through the name attribute.
Hope this can help.
Best regards,
Xudong Peng
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
None
0 Points
4 Posts
Pull *all* HTML and value data from current page
Feb 24, 2021 05:17 PM|dl0dth|LINK
I need to know the way to pull the current HTML "render" from ASP.NET, plus all the data fields that have been modified into their current state by the user using my application. The reason for this is to create a PDF hard copy of the Submitted data. If I can do this programmatically, I will avoid having to generate the PDF manually which is a rather complex form.
In my application's current state, the user form in HTML looks almost exactly like a paper form. This HTML form displays perfectly, and as plain HTML of the form itself, it renders to PDF perfectly. What this form is missing at this point is the data points that were edited into the HTML form before the Submit button was pressed.
Is it possible to have a Javascript script that will pull all the HTML and load the appropriate value pairs with all data that currently exists on the page? My PDF also shows the default selections for radio buttons, etc, but what if the user selects something that moves this selection to another item? Can a javascript script account for that and set the appropriate field?
In a nutshell, what I'm trying to do is upon Submit, collect the state of the page ASP.NET would know it and simply produce the HTML string from the current state instead of have to manually do anything with the page or the PDF I'm trying to create.
Contributor
2370 Points
743 Posts
Re: Pull *all* HTML and value data from current page
Feb 25, 2021 06:04 AM|XuDong Peng|LINK
Hi dl0dth,
You can use document.documentElement.innerHTML to get all the html text after the page is loaded.
And use Javascript script to get the value of each element through the selector. When the user modifies the value of the relevant element, you could use some events like onchange() to modify the html text content accordingly.
For more information about selectors, you can refer to this document: https://www.w3schools.com/css/css_selectors.asp
When you submit to the server, you can still get the form data in the request, and then get the value of these elements values through the name attribute.
Hope this can help.
Best regards,
Xudong Peng