HTMLPlaceholder UrlLoaded not firing

15 posts, 0 answers
  1. Brad
    Brad  avatar
    9 posts
    Member since:
    Jun 2012

    Posted 22 Nov 2010 Link to this post

    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
     
     
     
     
     

  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 24 Nov 2010 Link to this post

    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
  3. DevCraft banner
  4. Brad
    Brad  avatar
    9 posts
    Member since:
    Jun 2012

    Posted 24 Nov 2010 Link to this post

    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
  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 26 Nov 2010 Link to this post

    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
  6. Brad
    Brad  avatar
    9 posts
    Member since:
    Jun 2012

    Posted 01 Dec 2010 Link to this post

    Perfect, thank you.
  7. Robert
    Robert avatar
    13 posts
    Member since:
    Aug 2011

    Posted 26 Aug 2011 Link to this post

    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);
  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 01 Sep 2011 Link to this post

    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 >>

  9. Robert
    Robert avatar
    13 posts
    Member since:
    Aug 2011

    Posted 01 Sep 2011 Link to this post

     
  10. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 01 Sep 2011 Link to this post

    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 >>

  11. B
    B avatar
    5 posts
    Member since:
    Jun 2008

    Posted 01 Feb 2012 Link to this post

    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

  12. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 06 Feb 2012 Link to this post

    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 >>
  13. B
    B avatar
    5 posts
    Member since:
    Jun 2008

    Posted 06 Feb 2012 Link to this post

    Hi,

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

    Any more ideas?
    Cheers
  14. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 09 Feb 2012 Link to this post

    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 >>
  15. B
    B avatar
    5 posts
    Member since:
    Jun 2008

    Posted 08 Mar 2012 Link to this post

    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
  16. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 12 Mar 2012 Link to this post

    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 >>
Back to Top
DevCraft banner