Showing a modal dialog box or form when the application is not running in UserInteractive mode

Hi all I am getting this error when my site was in live when trying to show print preview dialog

PrintPreviewDialog ppdlg = new PrintPreviewDialog();

ppdlg.ShowDialog();

How can I resolve this error

Complete error

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

Answers


In asp.Net, you can't use PrintPreviewDialog class because it's part of windows form. The asp.net code runs on the server side.

If you want to popup a print dialog with asp.net, you have to do it on client side.

This can be achieved by a combination of a custom css for print and a bit of javascript. Here can be a good starting point : http://www.javascriptkit.com/dhtmltutors/cssmedia.shtml


Need Your Help

Value bringing back Null

java android

I have a social app that builds a list of cars for users. Each user builds their own list. When I click on a listview item to link car data with dealership data I bring back a null value in the be...

import python class into another folder in a package

python import module flask

I'm trying to import a python class from another folder of my python package but I this error "No module named models".