Issue with Ajax Rating Control not displaying when printing through JavaScript

I have a rating control implemented using Ajax in my aspx page. However, when I try to print the page using JavaScript, the rating control does not appear in the printed version or print preview. Does anyone have a solution for this issue? Below is the tag for my Rating control:

<ajaxToolkit:Rating ID="rtDriverRating" AutoPostBack="false" runat="server" MaxRating="5" StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star" FilledStarCssClass="FilledStar" ReadOnly="true"></ajaxToolkit:Rating>

This is the JavaScript function used for printing:

function printdiv(printpage) {
    var headstr = "<html><head><title></title></head><body>";
    var footstr = "</body>";
    var newstr = document.all.item(printpage).innerHTML;
    var oldstr = document.body.innerHTML;
    document.body.innerHTML = headstr + newstr + footstr;
    window.print();
    document.body.innerHTML = oldstr;
    //window.location.reload();
    return false;
}

Upon inspecting the page, this is what I found:

<a href="javascript:void(0)" id="ContentPlaceHolder1_rtDriverRating_A" title="5" style="text-decoration:none"><span id="ContentPlaceHolder1_rtDriverRating_Star_1" class="FilledStar" style="float:left;">&nbsp;</span><span id="ContentPlaceHolder1_rtDriverRating_Star_2" class="FilledStar" style="float:left;">&nbsp;</span><span id="ContentPlaceHolder1_rtDriverRating_Star_3" class="FilledStar" style="float:left;">&nbsp;</span><span id="ContentPlaceHolder1_rtDriverRating_Star_4" class="FilledStar" style="float:left;">&nbsp;</span><span id="ContentPlaceHolder1_rtDriverRating_Star_5" class="FilledStar" style="float:left;">&nbsp;</span></a>

The appearance of the rating control on the page can be seen here: Ajax Rating control on the page

Edit: Including my CSS code:

.Star {
    background-image: url(/Content/imgs/images/Star.gif);
    height: 17px;
    width: 17px;
}

.WaitingStar {
    background-image: url(/Content/imgs/images/WaitingStar.gif);
    height: 17px;
    width: 17px;
}

.FilledStar {
    background-image: url(/Content/imgs/images/FilledStar.gif);
    height: 17px;
    width: 17px;
}

Answer №1

Resolved the issue with the help of @nuts-n-beer's solution from the discussion on How can I force browsers to print background images in CSS? Turns out, the stars were set as a background element. I had to add "no-repeat !important" to the css background property in order to enable printing background graphics. Here is my updated css code snippet:

.Star {
    background: url(/Content/imgs/images/Star.gif) no-repeat !important;
    height: 17px;
    width: 17px;
}

If anyone has a method to display the images without requiring the user to enable print background graphics, I would greatly appreciate it.

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

What is the best way to prevent event propagation while still allowing a modal to function correctly?

I have a scenario where I want to prevent a table row (<tr>) from receiving a click event when one of two buttons inside it is clicked. To achieve this, I've added an event handler that stops the propagation of the click event. $(".btn").on(&ap ...

Angular Dynamic Alert Service

Is it possible to customize the text in an Angular Alert service dynamically? I'm looking to make certain words bold, add new lines, and center specific parts of the text. Specifically, I want the word "success" to be bold and centered, while the rest ...

What steps do I need to take for webpack to locate angular modules?

I'm currently in the process of setting up a basic application using Angular 1 alongside Typescript 2 and Webpack. Everything runs smoothly until I attempt to incorporate an external module, such as angular-ui-router. An error consistently arises ind ...

How can I delete the visuals and objects from my mind in Three.js?

I need to place a specific number of circles on the scene. var radius = 1; var segments = 32; var circleGeometry = new THREE.CircleGeometry( radius, segments); function generateCircles(){ //scene.remove(circle); var count=0; while (1000> count ...

The response from the service worker fetch did not include the "Content-Length" header

Currently, I am fetching static assets such as images and PDFs from AWS S3 and providing download progress updates to the client using the service worker API. My method involves reading the "content-length" header in the response. Interestingly, this appro ...

How to Use Linq to Retrieve the Latest Status in an ASP.NET Application

https://i.sstatic.net/vuzdA.jpg I have a collection of PipelineJobStatuses that combine information from db.Pipelines and db.JobStatuses. Each PipelineID can have multiple statuses and I need to find the latest one. I want to retrieve this information and ...

How can values be populated from an input box in the background in Vue.js?

I'm working on a project that involves Vue.js and Quasar. One of the requirements is an input field initialized with 10 zeros, only allowing numeric numbers. The catch is that when adding a number, it should fill in from behind. "0000000000" -> a ...

Optimize your React application by eliminating debug code before deploying it to production

Currently, I am developing a React App within an npm environment. Throughout my JavaScript code, I have the following snippet in multiple JS files: ... let url = loc.protocol + "//" + loc.hostname + (loc.port ? ":" + loc.port : "") + "/" + baseUrl; if (D ...

Adjust website aesthetics through JavaScript by modifying its CSS styling

Hello, in my PHP application I am looking to update the style using JavaScript. <div id="middle-cnt" class="ad-image-wrapper"><div class="ad-image" style="width: 1000px; height: 450px; top: 0px; left: 131px;"><img height="450" width="1000" ...

The mystery surrounding why PartialView doesn't refresh using Ajax in MVC

I have a popup window that I use to create a new record, where I render a view within the window. Additionally, based on the selected index of a combobox in this view, I call a partialview. While I can successfully post the form to the Controller and retur ...

I am encountering the "Error converting data type nvarchar to int" message in my ASP application, although everything is running smoothly in the desktop application

I currently have a stored procedure that needs to be edited: ALTER procedure [dbo].[editUserInfo] (@userid int, @firstName varchar(50), @lastName varchar(50), @contact varchar(50), @address varchar(50), @info varchar(100), @username varchar(50), @passwor ...

Retrieve the Response object when an ASP.NET Button is clicked

Within my ASP.NET Webform, I have a server-side Button with an Onclick event registered on it. <asp:Button ID="UploadButton" CssClass="btn add btn-primary" runat="server" Text="Upload File" OnClick="UploadBut ...

JS instant Toggle (just one click) - initial value of toggled item

Can you explain why we have to click twice on this link (http://jsfiddle.net/xL8hyoye/4/): html: <a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a> <div id="foo">This is foo< ...

What steps can be taken to prompt the layout to transition?

I have an element that sticks to the top based on the current scroll offset. The issue is that the layout doesn't update when there is space available after the stuck element. This creates a ghost gap where the stuck element used to be... http://fidd ...

Retrieve a subsection of an object array based on a specified condition

How can I extract names from this dataset where the status is marked as completed? I have retrieved this information from an API and I need to store the names in a state specifically for those with a completed status. "data": [ { "st ...

Special character object properties in EJS

Currently, I am developing a website which involves using a language file structured like this: replace = { "x:a": "Hello", "x:b": "World!", "y:c.d": "Another text" } My goal is to pa ...

The array is giving back null values

When making a POST request with AJAX and sending data in JSON format, everything seems to be working fine until trying to print out a specific index value from the decoded array, which returns null. What could be causing this issue? Here's the AJAX re ...

"What is the best way to send a stateful array from a child component to a parent component using React Hooks

Within my CreateArea component, I collect user input data and store it in a local state array called notes using setNote. My goal is to display multiple Note components below the CreateArea component, with each component corresponding to an item in the no ...

How to retrieve the ID of a table column using jQuery in HTML

I am facing an issue with a HTML table that consists of only one row and one column: <table id="backlog"> <colgroup> <col width="200"></colgroup> <tbody> <tr><td id="91" tabindex="0" class="mark">BackLog&l ...

Design of sections for details on third-party payment services configuration

Recently, I integrated a third-party payment platform called PayFast for handling subscriptions on the website I'm currently developing. The configuration file is now cluttered with numerous items under the AppSettings node that start with 'PayFa ...