Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > HTMLPlaceHolder > HTMLPlaceholder UrlLoaded not firing

Not answered HTMLPlaceholder UrlLoaded not firing

Feed from this thread
  • Brad avatar

    Posted on Nov 22, 2010 (permalink)

    While using the Silverlight RadHTMLPlaceholder I've assembled a wait indicator that ends on the "UrlLoaded" event.  The event actually fires when redirecting to common links like www.google.com, etc., but it doesn't in my particular instance.  I'm redirecting to an ASPX page within the solution that renders a PDF into a Byte array and writes it to the page.  Everything works wonderfully aside from firing the UrlLoaded event which, again, is only being used to stop the wait indicator...  Yes, I have OCD.  :)

    Here is the page's code (reduced for easy reading):

    Private Sub RunReport(ByVal ReportName As String)

     Dim iReport As LocalReport

     Select Case ReportName

      Case "Bankruptcy"
       ' Set up the report parameters
       Dim iDate As Date = Request.QueryString("date")
       
       ' Grab the data
       Dim iBankruptData As DataSet = DBAccess.SRReports.GetBankruptcyAndDelinquency(iDate)
       
       ' Set the data sources
       Dim iData1 As New ReportDataSource("Bankruptcy", iBankruptData.Tables(0))
       Dim iData2 As New ReportDataSource("Delinquency", iBankruptData.Tables(1))
       
       ' Add the parameters
       Dim iReportParms(0) As ReportParameter
       iReportParms(0) = New ReportParameter("ReportDate", CDate(iDate), False)
       
       ' Set up the report
       iReport = New LocalReport With {.ReportPath = Server.MapPath(".") & "\Bankruptcy.rdlc", .DisplayName = "Bankruptcy"}
       iReport.SetParameters(iReportParms)
       iReport.DataSources.Clear()
       iReport.DataSources.Add(iData1)
       iReport.DataSources.Add(iData2)
      End Select
      
     ' Set up the rendering parameters
     Dim iReportType As String = "PDF"
     Dim iDeviceInfo As String = Nothing
     Dim iMimeType As String = Nothing
     Dim iEncoding As String = Nothing
     Dim iFileNameExtension As String = "PDF"
     Dim iWarnings As Warning() = Nothing
     Dim iStreams As String() = Nothing
     
     ' Render the report
     Dim iReportBytes As Byte()
     iReportBytes = iReport.Render(iReportType, iDeviceInfo, iMimeType, iEncoding, iFileNameExtension, iStreams, iWarnings)
     
     ' Now, let's display the report as a new pdf
     
     With Response
      .ClearHeaders()
      .ClearContent()
      .Buffer = True
      .ContentType = "application/pdf"
      .AddHeader("Content-Disposition", "inline;filename=" & ReportName & ".pdf;")
      '.AddHeader("Content-Disposition", "attachment;filename=" & ReportName & ".pdf") ' For displaying in client's default PDF reader
      .AddHeader("Content-Length", iReportBytes.Length.ToString())
      .BinaryWrite(iReportBytes)
      .Flush()
      .End()
     End With
    End Sub
     
     
     
     
     

    Reply

  • Kiril Stanoev Kiril Stanoev avatar

    Posted on Nov 24, 2010 (permalink)

    Hello Brad ,

    I tested a very simple scenario where I load an ASPX page from my solution into an HtmlPlaceholder and UrlLoaded fires every time. I tested this scenario in IE8, Firefox and Chrome.

    Here is the output of the test. Also I am attaching my test project for further reference. Could you please take a look at it and let me know if I am missing something.

    Sincerely yours,
    Kiril Stanoev
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight

    Reply

  • Brad avatar

    Posted on Nov 24, 2010 (permalink)

    Thank you Kiril for your response.

    I can get the UrlLoaded event to fire as you did (I mentioned this earlier).  I'm wondering why it doesn't fire when rendering/writing a PDF with Response.BinaryWrite(myByteArray).

    Please review the code

    Reply

  • Kiril Stanoev Kiril Stanoev avatar

    Posted on Nov 26, 2010 (permalink)

    Hi Brad ,

    Thank you for the clarification. The reason why UrlLoaded is not fired is because by saying Response.BinaryWrite(iReportBytes), the page is no longer html page but pdf. One way to workaround that is to put the ASPX that contains the pdf into another ASPX and pass the second ASPX as SourceUrl to the HtmlPlaceholder. This is what I mean:
    Imaging you have your ASPX page (ex. WebForm1.aspx) that renders the PDF file:



    If you pass WebForm1.aspx as SourceUrl to RadHtmlPlaceholder, the UrlLoaded event will not be fired.

    <telerik:RadHtmlPlaceholder SourceUrl="../WebForm1.aspx" Width="500" Height="500"
            UrlLoaded="RadHtmlPlaceholder_UrlLoaded" />

    Instead, you can create an additional ASPX page (WebForm2.aspx) and insert WebForm1.aspx in it:



    Then pass WebForm2.aspx as SourceUrl to RadHtmlPlaceholder:

    <telerik:RadHtmlPlaceholder SourceUrl="../WebForm2.aspx" Width="500" Height="500"
            UrlLoaded="RadHtmlPlaceholder_UrlLoaded" />

    Take a look at the attached project for further reference and let me know if it works for you.

    All the best,
    Kiril Stanoev
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight

    Reply

  • Brad avatar

    Posted on Dec 1, 2010 (permalink)

    Perfect, thank you.

    Reply

  • Chris avatar

    Posted on Aug 26, 2011 (permalink)

    Unfortunately this solution doesn't work if you have to set the content disposition as shown below (thus forcing the user to choose).  I copied what you suggested above, whereby I have an aspx "hosting" page that contains an iframe whose src equals an ashx handler that outputs the binary file.  It doesn't work if you do this below, even though it's in an iframe.  Ideas?
    context.Response.AddHeader("content-disposition", "attachment; filename=" + filename);

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Sep 1, 2011 (permalink)

    Hi Chris,

     We need some more time in order to investigate this deeper. We'll write you back the next few hours. Thank you for your understanding.

    Regards,
    Petar Mladenov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Reply

  • Chris avatar

    Posted on Sep 1, 2011 (permalink)

     

    Reply

  • Kiril Stanoev Kiril Stanoev avatar

    Posted on Sep 1, 2011 (permalink)

    Hi Chris,

    We investigated this issue and weren't able to exactly pinpoint the cause for it. However I stumbled upon this interesting discussion on StackOverflow. Take a look at it and let me know if helps.

    All the best,
    Kiril Stanoev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Reply

  • B avatar

    Posted on Feb 1, 2012 (permalink)

    Hi

    I have the same issue. But I can confirm that the sample project you provided works. However if you changed the source URL is an external domain address it does not work. Is there a way to make it work with an external domain?

    Cheers Bruce

    Reply

  • Kiril Stanoev Kiril Stanoev avatar

    Posted on Feb 6, 2012 (permalink)

    Hello Bruce,

    Try modifying the WebForm1.aspx.cs to look like the following:

    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            WebClient client = new WebClient();
            byte[] bytes = client.DownloadData(new Uri("http://www.biometrics.gov/documents/fingerprintrec.pdf", UriKind.RelativeOrAbsolute));
            Response.BinaryWrite(bytes);
        }
    }

    Give it a try and let me know how it goes. I'd be glad to further assist you.

    Regards,
    Kiril Stanoev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • B avatar

    Posted on Feb 6, 2012 (permalink)

    Hi,

    Thanks for the reply. I am using Silverlight so the Web client does not have the DownloadData method.

    Any more ideas?
    Cheers

    Reply

  • Kiril Stanoev Kiril Stanoev avatar

    Posted on Feb 9, 2012 (permalink)

    Hi B F,

    If your application is out-of-browser then you can try using one of WebClient's available methods. For example, DownloadStringAsync() or OpenReadAsync(). 

    For a regular in-browser application, RadHtmlPlaceholder needs a web server where you can implement the approach previously suggested.

    All the best,
    Kiril Stanoev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • B avatar

    Posted on Mar 8, 2012 (permalink)

    Hi,

    The application is in borwser so this option is not aviable. And the previously suggested solution does not work.

    The Applciation is in broswer with a cross domain call. The URL loaded does not fire.

    Cheers Bruce

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Mar 12, 2012 (permalink)

    Hi B,

     Since you use an in-browser approach, why don't you use a Page_Load event of a Page in your Web Project? Could you please elaborate more on your exact scenario? We could change this ticket's type to GeneralFeedback so that you will be able to attach files, or you can directly open a new support ticket. This way we would be better able to investigate your scenario and advice you. Thank you in advance for your cooperation.

    Greetings,
    Petar Mladenov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > HTMLPlaceHolder > HTMLPlaceholder UrlLoaded not firing
Related resources for "HTMLPlaceholder UrlLoaded not firing"

Silverlight HtmlPlaceHolder Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]