This is a migrated thread and some comments may be shown as answers.

Is the PDFViewer supposed to work in an aspx page that host a silverlight app?

1 Answer 63 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Jason Maronge
Top achievements
Rank 1
Jason Maronge asked on 06 Mar 2012, 07:45 PM
Is the PDFViewer supposed to work in an aspx page that host a silverlight app?  Basically I am trying to create an installer page that host a pdfviewer for our EULA with a button to install the SL app.  I have stepped through the control and it works fine expect when the document is done loading (loading image finishes) the whole SL part disappears. 

My app loads a SL page with a pdfviewer that loads it like so:

pdfViewer.DocumentSource = new PdfDocumentSource(new Uri(Tools.GetHostUri() + @"Docs/EULA.pdf"));

If I run this inside my SL OOB app it works great but I can't figure out what is the problem.  There is no error that appears or that is thrown.

IE:
<%@ Page Language="C#" AutoEventWireup="true" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
    <meta http-equiv="EXPIRES" content="Mon, 22 Jul 2002 11:12:01 GMT">
    <title>CEO</title>
    <style type="text/css">
        html, body
        {
            height: 100%;
            overflow: auto;
        }
        body
        {
            padding: 0;
            margin: 0;
        }
        #silverlightControlHost
        {
            height: 100%;
            text-align: center;
        }
        #sl
        {
            width: 847px;
            height: 637px;
        }
        .style1
        {
            width: 100%;
        }
    </style>
    <script type="text/javascript" src="Silverlight.js"></script>
    <script type="text/javascript">
        document.onkeydown = function () {
 
            var keycode = event.keyCode
 
            if (keycode == 116) {
                event.keyCode = 0;
                event.returnValue = false;
                return false;
            }
        }
 
 
        function onSilverlightError(sender, args) {
            throw new Error("");
            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }
 
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;
 
            if (errorType == "ImageError" || errorType == "MediaError") {
                return;
            }
 
            var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";
 
            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";
 
            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " + args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }
 
            throw new Error(errMsg);
        }
    </script>
</head>
<body oncontextmenu="return false">
    <form id="form1" runat="server" style="height: 100%">
    <div id="silverlightControlHost">
        <table class="style1">
            <tr>
                <td>
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Logo.png" />
                </td>
            </tr>
            <tr>
                <td>
                    <br />
                            GOT SOME STUFF GOING ON HERE IN HTML
                    <br />
                </td>
            </tr>
            <tr>
                <td>
                    <object id="sl" height="450" width="525" data="data:application/x-silverlight-2," type="application/x-silverlight-2" >
                        <param name="source" value="ClientBin/SL.xap" />
                        <param name="onError" value="onSilverlightError" />
                        <param name="background" value="white" />
                        <param name="minRuntimeVersion" value="5.0.61118.0" />
                        <param name="uiculture" value="<%= System.Threading.Thread.CurrentThread.CurrentUICulture %>" />
                        <param name="culture" value="<%= System.Threading.Thread.CurrentThread.CurrentCulture %>" />
                        <param name="autoUpgrade" value="true" />
                        <param name="initParams" value="runInstaller=true" />
                        <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration: none">
                            <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"
                                style="border-style: none" />
                        </a>
                    </object>
                </td>
            </tr>
             
        </table>
        <iframe id="_sl_historyFrame" style="visibility: hidden; height: 0px; width: 0px;
            border: 0px"></iframe>
    </div>
    </form>
</body>
</html>

 
I hope this makes sense. 

Thanks,

Jason

1 Answer, 1 is accepted

Sort by
0
Kammen
Telerik team
answered on 09 Mar 2012, 02:46 PM
Hi Jason,

It is possible to use the RadPdfViewer in an aspx page, which hosts a Silverlight application.
Please find attached a demo illustrating how you can have mixed content in the aspx page.
I hope this helps.

Kind regards,
Kammen
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
PDFViewer
Asked by
Jason Maronge
Top achievements
Rank 1
Answers by
Kammen
Telerik team
Share this question
or