Generate some text on the following page utilizing the JavaScript function window.print()

Within my ASP.NET MVC View, I included this code snippet to display the content of my webpage:

var newWindow = window.open();
newWindow.document.write();

newWindow.document.write(document.getElementById("sbmtform").innerHTML);
newWindow.print();

I also have a separate div that needs to be printed on the next page within the same document. Can you please provide instructions on how to add pages or navigate to the next page in order to write my content?

Answer №1

To create a page break for printing, you can use the following CSS directive:

@media print {
    .mynewpage {page-break-after: always;}
}

Then in your HTML code, add the following line:

<br class="mynewpage">

For more information, you can refer to this link.

If you don't have access to CSS, you can also apply the page break directly in HTML like this:

<br style="page-break-after: always;">

Answer №2

Have you considered utilizing a reporting tool for creating and printing data-based documents instead of expecting your end-users to print the entire web page with UI controls? Check out this link for a demo of a possible reporting tool that could be beneficial.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Display the information in the second dropdown menu once the selection has been made in the first dropdown menu

I've successfully implemented a feature where selecting an option from the first drop-down list populates the second drop-down list accordingly. The HTML code snippet is as follows: <select size="1" id="BodyPart" title="" name="BodyPart"> ...

Issues have been encountered with the $ajax done function in an ASP.NET - MVC5 application

When using the $ajax jQuery function in a partial Razor view to retrieve another partial view with strongly typed model data from a controller and display it in a specific div, everything works fine when there is model data available. However, if there is ...

Is it possible to send variables within an ajax request?

I'm currently in the process of building my own website, and I have a specific requirement where I need to display different queries based on which button is clicked. Can this be achieved using the following code? Here's the HTML snippet: <d ...

The deployment of my Node application on Heroku is causing an error message: node-waf is not

I've been trying to deploy my Node.js application on Heroku by linking it to my Github repository and deploying the master branch. Despite experimenting with various methods, I keep encountering the same error every time. You can view the detailed b ...

Even when using module.exports, NodeJS and MongoDB are still experiencing issues with variable definitions slipping away

Hello there, I'm currently facing an issue where I am trying to retrieve partner names from my MongoDB database and assign them to variables within a list. However, when I attempt to export this information, it seems to lose its definition. Can anyone ...

The function slice is not a method of _co

I'm attempting to showcase the failedjobs array<any> data in a reverse order <ion-item *ngFor="let failjob of failedjobs.slice().reverse()"> An issue arises as I encounter this error ERROR TypeError: _co.failedjobs.slice is not a fu ...

Encountering NotFoundHttpException with Jquery Ajax in Laravel 4

Hello everyone! I'm diving into the world of ajax and currently experimenting with sending form input to a controller through a route and then displaying it in a div. Unfortunately, I've hit a roadblock as I keep getting a NotFoundHttpException ...

Dynamic computed subcomponents in Vue.js are a powerful way to create flexible

Currently, I am facing a scenario where I need to create computed local subcomponents. Specifically, I am working on custom data grid row cell components. Here is an example of what I am trying to achieve: var DataGridRow = { props: ['columns&ap ...

A guide to showcasing data within PrimeNG's pie chart component using either JavaScript or Angular

I have utilized the pie chart feature from the PRIMENG CHART PLUGIN My goal is to showcase the values within a pie chart Below, you can find my code for reference **Within app.component.html** <div style="display: block"> <p-chart type="pi ...

Refreshing a webpage using AJAX from a different URL of a secondary web service

I am working on a page that retrieves data from a specific web service URL. I am conducting some processing involving a multiple choice checkbox, and I want the same page to reload and fetch its data from a second web service with a different URL to retrie ...

Tips for dynamically adding an HTML element to index.html using JavaScript

https://i.sstatic.net/cAna8.png How can I use JavaScript to insert cards into a container or display them in flex? Currently, the cards are not displaying as desired. I attempted to insert data into the note class using insertAdjacentHTML in JavaScript, b ...

Completely different method for transmitting an array to NodeJS through AJAX

Recently, I've encountered difficulties when sending arrays to NodeJS using AJAX. It seems that whenever I try to send it with JSON, the error function is always triggered. Despite seeking explanations, I haven't found a satisfactory answer. The ...

the ever-changing dimensions of a PDF document

I'm attempting to display a PDF using an iframe, but I want the height of the viewer to match the document's height, meaning that all 3 pages should be visible without scrolling. How can I achieve this? Here's a simple example I created on ...

Is there a delay in Javascript identifying user existence when retrieving values from ajax?

I'm working on a script that checks if a username already exists before allowing a visitor to proceed. Here's a snippet of the code I'm using: EDIT: I've made some adjustments based on your feedback, but I'm still having trouble g ...

Tap to reveal additional information with the power of Jquery and ajax

I have a question regarding the popup slide functionality. I would like to achieve the following: Currently, I am using the following code to display post details upon clicking: function getPostDetails(id){ var infoBox = document.getElementById("in ...

Tips for effectively engaging with a Component's aggregationUnleash the full potential of

After configuring an aggregation for my Component, here is what it looks like: aggregations : { busyDialog : { type: "sap.m.BusyDialog", multiple: false } } The aggregation is named ...

Prevent the onscroll animation of the SVG from activating immediately upon its appearance on the screen

I am in the process of building a website that incorporates SVG technology. My issue is with some SVG icons that have animated effects when scrolling, but the animation triggers as soon as they come into view. What I really need is for these icons to sta ...

What are some alternative methods for updating content with ajax in ASP.Net web forms aside from using UpdatePanels?

In my experience with web UI development, I have gained a strong understanding of ASP.Net Web Forms over the course of four years. However, I have struggled to find an efficient way to update sections of a page using Ajax. I have tried various methods invo ...

Error in SQL query: mistaking a value for a column name while updating a

Could someone explain why these code snippets are generating a SQL error? Error: Invalid column name Poe I seem to be unable to spot any issues in this code (except for perhaps the variable names) Updated code: index.cshtml if(IsPost) { var it = ...

Graphic selectors: a new take on radio buttons

I've been attempting to make this work, but it's not functioning correctly. Below is the CSS code: .input_hidden { position: absolute; left: -9999px; } .selected { background-color: #000000; } #carte label { display: inline-bl ...