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

Javascript error when click print function in a RadAjaxPanel

1 Answer 53 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 2
Phil asked on 17 Apr 2012, 03:26 PM
Hi:
I just placed my working chart inside a RadAjaxPanel and the print functionally is giving me a javascript runtime error on the { before the finally.

try{a._webRequest.completed(Sys.EventArgs.Empty)}finally{if(a._xmlHttpRequest!=null)

The JScript message says, it may be caused by response.write.

Using _ms As System.IO.MemoryStream = New System.IO.MemoryStream()
    _radChart.Save(_ms, System.Drawing.Imaging.ImageFormat.Png)
    page.Response.Clear()
    page.Response.ClearHeaders()
    page.Response.AddHeader("Content-disposition", "attachment; filename=" & pngName & ".png")
    page.Response.AddHeader("Content-type", "image/png")
    page.Response.BinaryWrite(_ms.ToArray())
    page.Response.End()
End Using
So, there is the response write.  So, how am I supposed to get the PNG image to the users?
Phil

1 Answer, 1 is accepted

Sort by
0
Phil
Top achievements
Rank 2
answered on 18 Apr 2012, 04:22 PM
Hi:
I write a post at asp.net forum and I get 4 suggestion in the first hour, not so here.

So, my solution has been write it to a file:
' Delete the file first
Using _fs As System.IO.FileStream = New FileStream(_fileName, FileMode.CreateNew)
    _radChart.Save(_fs, System.Drawing.Imaging.ImageFormat.Png)
End Using

Then in javascript, I launch a window (not RadWindow), to load the file in my Download.ashx.  It is strange though, I had to call an established javascript function.
function LaunchJavaScriptWindow(windowName, formPath) {
    var app = '<%= Request.ApplicationPath %>';
    if (app == '/') app = '';
    var aspx = app + formPath;
    window.open(aspx, windowName, 'scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,width=800,height=550', false);
}

Phil
Tags
Chart (Obsolete)
Asked by
Phil
Top achievements
Rank 2
Answers by
Phil
Top achievements
Rank 2
Share this question
or