locked
Pull *all* HTML and value data from current page RRS feed

  • Question

  • User2097455209 posted

    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.

    Wednesday, February 24, 2021 5:17 PM

All replies

  • User-939850651 posted

    Hi dl0dth,

    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.

    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

    Thursday, February 25, 2021 6:04 AM