当尝试从 silverlight 4.0 应用程序打印 radgridview 数据时,如何解决 Firefox 冻结和崩溃的问题?

发布于 2025-01-07 17:30:44 字数 4519 浏览 1 评论 0原文

我正在使用在 Microsoft Windows XP Professional Version 2002 Service Pack 3 上运行的 Mozilla Firefox 8.0.1。当我尝试通过选择 hp Laser jet 1320 PCL 5 打印机或 Microsoft XPS Document Writer 进行打印时,浏览器崩溃。

注意:“打印”对话框仅显示“进度:准备”。如果我单击对话框或浏览器 它说该程序没有响应。我重新启动浏览器并重置打印首选项(print_printer),但这并不能解决我的问题。

我正在使用 Visual Studio 2010 从我的 silverlight 4.0 应用程序打印 radgridview(Telerik 控件之一)数据。对于较少的数据量,它工作得很好,但是当我们处理大量数据时,它只会崩溃 Firefox,而不是其他浏览器(例如 IE), Chrome、Safari 等...

有什么办法可以解决这个问题吗?

这是我的代码:

Xaml.cs 页面

private void PrintButton_Click(object sender, RoutedEventArgs e)

    {
        try
        {
            rptDataGridData = new RadGridView();
            rptDataGridData = reportPlaceHolder.FindChildByType<RadGridView>() as RadGridView;
            if (rptDataGridData != null ? rptDataGridData.ItemsSource != null : false)
            {
                Telerik.Windows.Controls.ExportFormat format = Telerik.Windows.Controls.ExportFormat.Html;
                format = Telerik.Windows.Controls.ExportFormat.Html;
                MemoryStream ms = new MemoryStream();
                rptDataGridData.Export(ms,
                         new GridViewExportOptions()
                         {
                             Format = ExportFormat.Html,
                             ShowColumnHeaders = true,
                             ShowColumnFooters = true,
                             ShowGroupFooters = false,
                         });

                StringBuilder data = new StringBuilder();
                StreamReader streamReader = new StreamReader(ms);
                ms.Position = 0;
                streamReader.DiscardBufferedData();
                while (!streamReader.EndOfStream)
                {
                    data.Append(streamReader.ReadLine());
                }
    
                data = data.Replace("style=", "class=\"heading\" style=");
                string htmlContent = string.Format(
                    @"<style type='text/css'>
                        html, body {{
                                    font-family:Verdana, Arial, Helvetica, sans-serif;
                                }}
                        table {{
                            border-width: 1px;
                            border-spacing: 1px;
                            border-style: none;
                            border-color: gray;
                            border-collapse: collapse;
                            background-color: white;
                        }}
                        table td {{
                            border-width: 1px;
                            padding-left: 3px;c
                            padding-right: 15px;
                            padding-top:5px;
                            padding-bottom:3px;
                            border-style: inset;
                            border-color: gray;
                            background-color: white;
                            font-size:11px;
                        }}
                        table td.heading {{
                            border-width: 1px;
                            padding-left: 5px;
                            padding-right: 15px;
                            padding-top:5px;
                            padding-bottom:5px;
                            border-style: inset;
                            border-color: rgb(192, 192, 192);
                            font-weight: bold;
                        }}
                     </Style>
                    {0}"
                    , data.ToString());



                HtmlPage.Window.Invoke("WriteContent", new object[] { htmlContent });
            }
            else
            {
                MessageBox.Show("There is no data to print", MortalMessage.MortalErrorHeading, MessageBoxButton.OK);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message,MortalMessage.MortalErrorHeading,MessageBoxButton.OK);
        }
    }

aspx 页面

function WriteContent(contentToPrint) {
var ifrm = document.getElementById('frmPrint');
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow :                                       (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.document.open();
ifrm.document.write(contentToPrint);
ifrm.document.close();
ifrm.focus();
ifrm.print();

<iframe src="about:blank" runat="server" id="frmPrint" height="0" width="0" />

I am using Mozilla Firefox 8.0.1 running on Microsoft Windows XP Professional Version 2002 Service Pack 3.when i try to print by selecting hp laser jet 1320 PCL 5 printer or Microsoft XPS Document Writer, the browser is getting crash.

Note: The "printing" dialog shows "progess:preparing" alone. If I click on dialog or browser
it says the program is not responding. I restart browser and reset print preference (print_printer) but it is not solving my problem.

I am printing radgridview (one of the telerik control) data's from my silverlight 4.0 application with visual studio 2010.it is working fine for less amount of data but when we goes to large amount it is crashing only Firefox not other browsers such as IE, Chrome, Safari etc...

Is there any way to solve this problem?

Here is my code:

Xaml.cs page

private void PrintButton_Click(object sender, RoutedEventArgs e)

    {
        try
        {
            rptDataGridData = new RadGridView();
            rptDataGridData = reportPlaceHolder.FindChildByType<RadGridView>() as RadGridView;
            if (rptDataGridData != null ? rptDataGridData.ItemsSource != null : false)
            {
                Telerik.Windows.Controls.ExportFormat format = Telerik.Windows.Controls.ExportFormat.Html;
                format = Telerik.Windows.Controls.ExportFormat.Html;
                MemoryStream ms = new MemoryStream();
                rptDataGridData.Export(ms,
                         new GridViewExportOptions()
                         {
                             Format = ExportFormat.Html,
                             ShowColumnHeaders = true,
                             ShowColumnFooters = true,
                             ShowGroupFooters = false,
                         });

                StringBuilder data = new StringBuilder();
                StreamReader streamReader = new StreamReader(ms);
                ms.Position = 0;
                streamReader.DiscardBufferedData();
                while (!streamReader.EndOfStream)
                {
                    data.Append(streamReader.ReadLine());
                }
    
                data = data.Replace("style=", "class=\"heading\" style=");
                string htmlContent = string.Format(
                    @"<style type='text/css'>
                        html, body {{
                                    font-family:Verdana, Arial, Helvetica, sans-serif;
                                }}
                        table {{
                            border-width: 1px;
                            border-spacing: 1px;
                            border-style: none;
                            border-color: gray;
                            border-collapse: collapse;
                            background-color: white;
                        }}
                        table td {{
                            border-width: 1px;
                            padding-left: 3px;c
                            padding-right: 15px;
                            padding-top:5px;
                            padding-bottom:3px;
                            border-style: inset;
                            border-color: gray;
                            background-color: white;
                            font-size:11px;
                        }}
                        table td.heading {{
                            border-width: 1px;
                            padding-left: 5px;
                            padding-right: 15px;
                            padding-top:5px;
                            padding-bottom:5px;
                            border-style: inset;
                            border-color: rgb(192, 192, 192);
                            font-weight: bold;
                        }}
                     </Style>
                    {0}"
                    , data.ToString());



                HtmlPage.Window.Invoke("WriteContent", new object[] { htmlContent });
            }
            else
            {
                MessageBox.Show("There is no data to print", MortalMessage.MortalErrorHeading, MessageBoxButton.OK);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message,MortalMessage.MortalErrorHeading,MessageBoxButton.OK);
        }
    }

aspx page

function WriteContent(contentToPrint) {
var ifrm = document.getElementById('frmPrint');
ifrm = (ifrm.contentWindow) ? ifrm.contentWindow :                                       (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
ifrm.document.open();
ifrm.document.write(contentToPrint);
ifrm.document.close();
ifrm.focus();
ifrm.print();

<iframe src="about:blank" runat="server" id="frmPrint" height="0" width="0" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2025-01-14 17:30:44

尝试禁用您的附加组件,重新启动 Firefox,然后尝试打印。您可能安装了导致冻结的附加组件。

如何禁用附加组件?按住 Shift 键并单击 Firefox 以安全模式打开,禁用所有附加组件并重置工具栏和控件。单击进行更改并重新启动。

无论如何,我都会考虑升级您的 Firefox 版本 - 您将受益于更多的错误修复和改进。

Try disabling your add-ons, restarting Firefox, and trying to print. It's possible that you have installed an add-on that is causing the freeze.

How to disable add-ons? Shift+click on Firefox to open in Safe Mode, Disable All Add-Ons and Reset Toolbars and Controls. Click on Make Changes and Restart.

I would consider upgrading your version of Firefox anyway - you stand to benefit from many more bug-fixes and improvements.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文