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

HTMLPlaceholder UrlLoaded not firing

14 Answers 151 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 2
Brad asked on 22 Nov 2010, 08:04 PM

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
 
 
 
 
 

14 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 24 Nov 2010, 12:46 PM
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
0
Brad
Top achievements
Rank 2
answered on 24 Nov 2010, 06:26 PM
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
0
Kiril Stanoev
Telerik team
answered on 26 Nov 2010, 11:00 AM
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
0
Brad
Top achievements
Rank 2
answered on 01 Dec 2010, 06:00 PM
Perfect, thank you.
0
Robert
Top achievements
Rank 1
answered on 26 Aug 2011, 10:37 PM
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);
0
Petar Mladenov
Telerik team
answered on 01 Sep 2011, 07:00 AM
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 >>

0
Robert
Top achievements
Rank 1
answered on 01 Sep 2011, 07:41 AM
 
0
Kiril Stanoev
Telerik team
answered on 01 Sep 2011, 08:16 AM
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 >>

0
B
Top achievements
Rank 1
answered on 01 Feb 2012, 09:53 AM
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

0
Kiril Stanoev
Telerik team
answered on 06 Feb 2012, 10:14 AM
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 >>
0
B
Top achievements
Rank 1
answered on 06 Feb 2012, 10:29 AM
Hi,

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

Any more ideas?
Cheers
0
Kiril Stanoev
Telerik team
answered on 09 Feb 2012, 02:30 PM
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 >>
0
B
Top achievements
Rank 1
answered on 08 Mar 2012, 09:42 AM
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
0
Petar Mladenov
Telerik team
answered on 12 Mar 2012, 05:02 PM
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 >>
Tags
HTMLPlaceHolder
Asked by
Brad
Top achievements
Rank 2
Answers by
Kiril Stanoev
Telerik team
Brad
Top achievements
Rank 2
Robert
Top achievements
Rank 1
Petar Mladenov
Telerik team
B
Top achievements
Rank 1
Share this question
or