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

Skin disappears

1 Answer 73 Views
Notification
This is a migrated thread and some comments may be shown as answers.
Jonas
Top achievements
Rank 1
Jonas asked on 22 Oct 2013, 09:20 AM
Hi there,

I have the following scenario that I need to implement: 
1. Generate a pdf-file (serverside). This will take me about 10 seconds server-side
2. Send file to browser

While the file is generated, I need to display something to the user. I am currently using the Radnotification control for this.

My problem is:
While the file is generated the notification control loses its Skin. I have tried different approaches to solve it, but with no luck so far.
It is important to consider, that the generated pdf-file is sent to the by writing to the Response-object, which is not allowed when the trigger lies within an update panel. 

I suspect I must be missing some fundamental knowledge of the Telerik controls and hope you can guide me in the right direction. Below is my code.

Markup:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="notification.aspx.vb" Inherits="TelerikPlayground.notification" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Udskriv fakturaer</title>
    <script src="Scripts/jquery-1.6.4.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.9.2.js" type="text/javascript"></script>
    <telerik:RadScriptBlock ID="scriptBlock" runat="server">
        <script type="text/javascript">

            $(document).ready(function () {
                
                        $("#beskrivelseAntal").text("Notification text");
                        $("#NotificationDialog").show();
                        $('#butPrint').click();
                    
            });
        </script>
    </telerik:RadScriptBlock>
    
   
</head>
<body>
    
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
       
        <div style="margin-left: auto;margin-right: auto; width: 350px;margin-top:20px;">
        <asp:Button runat="server" ID="butPrint" OnClick="print_click" style="display: none;"/>
        
                <telerik:RadNotification ID="NotificationDialog" runat="server" Skin="WebBlue"  EnableRoundedCorners="true" Title="Working" Text="Working" VisibleOnPageLoad="True" Position="Center" ShowCloseButton="False" AutoCloseDelay="0" Width="350" ShowTitleMenu="false"/>
       
         </div>
      </telerik:RadAjaxPanel>
    </form>
</body>
</html>


Codebehind:
Imports System.IO

Public Class notification
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub


Protected Sub print_click(ByVal sender As Object, ByVal e As EventArgs)

    Threading.Thread.Sleep(3000)

    Dim ms As New MemoryStream(File.ReadAllBytes("c:\temp\jotch.pdf"))

      Response.Expires = 0
      Response.Buffer = True
      Response.ClearContent()
      Response.AddHeader("content-disposition", "inline; filename=" + "jotch.pdf")
      Response.ContentType = "application/pdf"
      Response.BinaryWrite(ms.ToArray())
      ms.Close()
      Response.End()
    End Sub



End Class





1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 23 Oct 2013, 02:39 PM
Hi Jonas,

You cannot send files during a partial postback, so I advise that you move the hidden button out of the RadAjaxPanel:
<asp:Button runat="server" ID="butPrint" OnClick="print_click" Style="display: none;" />
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">

With your current setup I only get a JavaScript error because the browser cannot parse the received data, which is expected in this case. At this point the notification looked fine on my end, however.

Also note that you need to use the client-side API of the RadNotification control to show it, i.e. the $find() method, e.g.:
$find("NotificationDialog").show();


I am attaching here a short video that demonstrates the proper functionality. Note how it does not use AJAX for the postback that will bring the PDF file to the browser.

Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Notification
Asked by
Jonas
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or