2012-06-11 87 views
0

大家好,我得到這個錯誤時,試圖顯示打印預覽對話框顯示一個模式對話框或形成當應用程序不UserInteractive模式

PrintPreviewDialog ppdlg = new PrintPreviewDialog(); 

ppdlg.ShowDialog(); 

如何解決時,我的網站在現場運行這個錯誤

完全錯誤

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.

+0

消息說這一切:你試圖顯示一個窗口服務的對話框,它本質上是非交互式的。簡短的答案是,你不能。 –

回答

0

在asp.Net,您不能使用PrintPreviewDialog上一流的,因爲它的窗戶組成部分。 asp.net代碼在服務器端運行。

如果您想要使用asp.net彈出打印對話框,您必須在客戶端執行此操作。

這可以通過自定義css打印和一些javascript的組合來實現。這裏可以是一個很好的起點:http://www.javascriptkit.com/dhtmltutors/cssmedia.shtml

+0

嗨,實際上,我正在創建一個支票動態,當我點擊按鈕時創建了一個支票,我想在打印預覽中顯示 – Vivekh

+0

@Vivekh:?我的答案適用於這種情況。用css創建一個用於打印的html頁面,並在JS中調用print方法 –

相關問題