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

Can't get Notification working with server command

3 Answers 89 Views
Notification
This is a migrated thread and some comments may be shown as answers.
Egbert
Top achievements
Rank 1
Egbert asked on 30 Apr 2014, 10:07 AM
Hi,

I'm trying to show a notification when starting a time consuming function.
But no notification will popup.

What am I doing wrong:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ReportsGeneral.ascx.cs"
    Inherits="ReportsGeneral" %>
 
<%@ Register TagPrefix="uc" TagName="InfoPanel" Src="~/InfoPanel.ascx" %>
<%@ Register TagPrefix="uc" TagName="RisWindow" Src="~/RisWindow.ascx" %>
 
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
    <script type="text/javascript">
        function OnClientFilesUploaded(sender, args) {
            $find('<%=RadAjaxManager1.ClientID %>').ajaxRequest();
        }
    </script>
</telerik:RadScriptBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnablePageHeadUpdate="false">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadAsyncUploadReport" />
                <telerik:AjaxUpdatedControl ControlID="RadGridReports" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<div style="margin: 15px;">
    <center>
        <table>
            <tr>
                <td valign="top">
                    Begin
                    <telerik:RadCalendar ID="RadCalendar1" runat="server">
                    </telerik:RadCalendar>
                </td>
                <td rowspan="2" valign="top" style="margin-left: 10px; padding-left: 10px;">
                    Rapporten
                    <telerik:RadGrid ID="RadGridReports" runat="server" AllowPaging="True" ActiveItemStyle-Wrap="True"
                        ShowStatusBar="true" AllowSorting="True" AllowMultiRowEdit="true" AutoGenerateColumns="false"
                        AllowAutomaticInserts="true" OnNeedDataSource="RadGridReports_NeedDataSource" ClientSettings-Selecting-AllowRowSelect="true" ClientSettings-EnablePostBackOnRowClick="true"
                        OnItemCommand="RadGridReports_ItemCommand">
                        <MasterTableView PageSize="10" NoMasterRecordsText="No data">
                            <Columns>
                                <telerik:GridBoundColumn DataField="report_id" HeaderText="ID" UniqueName="id" Display="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="owner" HeaderText="Eigenaar" UniqueName="owner">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="filename" HeaderText="Rapport" UniqueName="filename">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="info" HeaderText="Info" UniqueName="info" Display="false">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true">
                        </ClientSettings>
                    </telerik:RadGrid>
                    <br />
                    <asp:Panel runat="server" GroupingText="Upload rapport">
                        <telerik:RadAsyncUpload ID="RadAsyncUploadReport" runat="server" OnFileUploaded="RadAsyncUploadReport_FileUploaded"
                            OnClientFilesUploaded="OnClientFilesUploaded" AllowedFileExtensions="xlsx" Localization-Select="Selecteer" Width="99%">
                        </telerik:RadAsyncUpload>
                        <br />
                    <uc:InfoPanel ID="InfoPanel1" runat="server" Type="note" Text="Je kan alleen rapporten uploaden met de .xlsx extensie!" HeaderText="Let op!"/>
                    </asp:Panel>
                    <br />
                    <div style="text-align: center">
                    <telerik:RadButton ID="buttonGenerateReport" runat="server" Text="Genereer rapport!" OnClick="buttonGenerateReport_Click" Skin="MetroTouch"></telerik:RadButton>
                    </div>
                </td>
            </tr>
            <tr>
                <td valign="top">
                    Eind
                    <telerik:RadCalendar ID="RadCalendar2" runat="server">
                    </telerik:RadCalendar>
                </td>
                <td>
                      
                </td>
            </tr>
        </table>
        <uc:RisWindow runat="server" ID="windowWarning" />
        <telerik:RadNotification ID="RadNotification" runat="server" Text="Initial text" Position="Center" AutoCloseDelay="0" Width="350" Title="Current time" EnableRoundedCorners="true" />
    </center>
</div>

Code to show the notification:
protected void buttonGenerateReport_Click(object sender, EventArgs e)
{
    if (this.RadGridReports.SelectedItems.Count <= 0)
    {
        this.windowWarning.Show("Selecteer eerst een rapport!");
        return;
    }
 
    // now start with the reporting
    string reportID = Session["ReportID"].ToString();
    string ownerID = dbReports.GetReportItem(reportID, "user_id");
    string reportFileName = dbReports.GetReportItem(reportID, "filename");
    string shortNameOwner = dbUser.GetUserItem(ownerID, "short_name");
 
    string completePath = Global.ReportFolder + shortNameOwner + "-" + reportFileName;
 
    this.RadNotification.Visible = true;
    this.RadNotification.VisibleOnPageLoad = true;
    this.RadNotification.Show();
 
    if (reportFileName.ToLower().StartsWith("vakantiekaart"))
    {
        ReportsVacation reportsVacation = new ReportsVacation();
        string reportResult = reportsVacation.CreateReport(completePath, reportFileName);
        if (reportResult != string.Empty)
        {
            this.windowWarning.Show(reportResult);
            return;
        }
    }
    else
    {
        ReportsStandard reportsStandard = new ReportsStandard();
        string reportResult = reportsStandard.CreateReport(completePath, reportFileName);
    }
 
    try
    {
        this.FileResponse(reportFileName, Global.ReportOutputFolder + reportFileName);
    }
    catch (Exception ex)
    {
        this.windowWarning.Show("Fout bij opslaan rapport: " + Global.ReportOutputFolder + reportFileName + "! Bestaat de folder?");
    }
}

Thanks and best regards,
Egbert

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Apr 2014, 10:41 AM
Hi Egbert,

Unfortunately I couldn't replicate the issue at my end. Please have a look into the sample project which works fine at my end.

Thanks,
Shinu.
0
Egbert
Top achievements
Rank 1
answered on 07 May 2014, 09:04 AM
Hi,

Thanks for the answer. 
Your code works fine and if a place a return; just after the following 3 lines of code it also works fine:

this.RadNotification.Visible = true;    
this.RadNotification.VisibleOnPageLoad = true;    
this.RadNotification.Show();

What I would like to do is to show a message just before Creating one or more reports:

if (reportFileName.ToLower().StartsWith("vakantiekaart"))
{......}

This CreateReport stuff can take up to 10 or 20secs so I would like to show a message like "Please wait, creating reports".

How can I show a warning and start creating the reports instead of showing the warning at the end of the function?

Thanks,
Egbert

0
Marin Bratanov
Telerik team
answered on 07 May 2014, 01:49 PM

Hi Egbert,

If you call the Show() method of the notification you do not need to set its VIsibleOnPageLoad property.

The thing is, both ways (Show() or VisibleOnPageLoad) need to travel to the client with the page response to have effect. The former is a script registration and the latter is merely a property setting the $create() statement takes.

Since you want the client to be notified without the response of the page, you would need to look into other connectivity options like SignalR. It can let you raise an event on the page from the server, and in this event you can use the notification's client-side API to set text and show it. The following blog post can help you get started: http://blogs.telerik.com/jefffritz/posts/13-02-01/signalr-with-radnotifications.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Notification
Asked by
Egbert
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Egbert
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or