iFrame没有看到pdf文档

iFrame没有看到pdf文档

本文介绍了iFrame没有看到pdf文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

您好,



我正在尝试从后面的代码中将pdf文档加载到iFrame中。我在页面加载后面的代码中使用以下代码:



Hello,

I am trying to load a pdf document into an iFrame from code behind. I am using the following code in code behind on Page Load:

if (Session["Document"].ToString() != string.Empty)
        {
            string document = Session["Document"].ToString();
            pdfIframe.Attributes.Add("src", document);
        }





当我使用内部网络服务器从Visual Studio 10内部运行它时它完美运行,但它确实有效当它上传到网站时它根本不起作用(它会抛出错误页面)其他所有内容(例如:数据库,查询等)都可以正常工作。

任何帮助表示赞赏。



我的尝试:



我已经完成了Google搜索并尝试了一些不同的代码变体。我将web.config文件更改为早期版本。我试图在Firefox和IE中运行它。没有运气。



It works perfectly when I run it from inside Visual Studio 10 using the internal web-server, but it does not work at all when it is uploaded to the website (it throws an error page) Everything else (eg: database, queries, etc.) works fine.
Any help appreciated.

What I have tried:

I have done a Google search and tried a few different code variations. I changed the web.config file to an earlier version. I have tried to run it in Firefox and IE. No luck.

推荐答案

//Using iFrame with Google Docs
        if (Session["Document"].ToString() != string.Empty)
        {
            string document = Session["Document"].ToString();
            string pdfPage = "http://docs.google.com/gview?url=" + document + "&embedded=true";
            pdfFrame.Attributes.Add("src", pdfPage);
        }
        else
        {
            ClientScriptManager script = Page.ClientScript;
            if (!script.IsClientScriptBlockRegistered(this.GetType(), "Alert"))
            {
                script.RegisterClientScriptBlock(this.GetType(), "Alert", "alert('Sorry, this document cannot be found. ')", true);
                return;
            }
        }


这篇关于iFrame没有看到pdf文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 08:27