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

OnAppointmentCreated is also fired after OnAppointmentClick

5 Answers 209 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Paula Bianca
Top achievements
Rank 1
Paula Bianca asked on 07 Jul 2008, 07:23 AM
When I clicked an appointment in RADScheduler, the AppointmentClick() event was fired.

I was trying to execute a javascript inside as described by the function below.


protected
void rsRadScheduler_AppointmentClick(object sender, Telerik.Web.UI.SchedulerEventArgs e)
{
    _EventID = Convert.ToInt32(e.Appointment.ID);

    String strJScript = "<script type=\"text/javascript\">alert('hello');</script>";
    this.Page.RegisterClientScriptBlock("EditEvent",strJScript);
}

But then the AppointmentCreated() event was also fired where I added some code to customize the event tooltip.

protected void rsRadScheduler_AppointmentCreated(object sender, Telerik.Web.UI.AppointmentCreatedEventArgs e)
{
    e.Appointment.ToolTip = GetTooltip(
Convert.ToInt32(e.Appointment.ID));
    _EventID =
Convert.ToInt32(e.Appointment.ID);
}

Thing is the javascript was registered without errors but it did not execute. It was as good as nothing happened when I clicked on the appointment. Only that the tooltip was displayed...

In place of the alert method, I was originally trying to open a RADWindow (javascript) inside the AppointmentClick method. But since that didn't work when I tried it, I wanted to test if any javascript will be executed inside the method. Unfortunately, nothing happened.

How will I be able to open a RADWindow on AppointmentClick()? Do you have other suggestions or approach that could help me do this?

Thank you...

5 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 07 Jul 2008, 02:07 PM
Hi Paula Bianca,

I tried to reproduce the problem exactly as you have described but everything worked normally.

I have attached my test page to this post for you to examine it.

Could you modify it so that it shows the erroneous behavior you are experiencing?

All the best,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Paula Bianca
Top achievements
Rank 1
answered on 08 Jul 2008, 12:23 AM
you said you attached the test page? ^__^
0
Paula Bianca
Top achievements
Rank 1
answered on 08 Jul 2008, 06:06 AM

 Hello again... I tried to isolate the problem by creating a new project with only the RADScheduler control in it, and created code behind for the OnAppointmentCreated and OnAppointmentClick methods. With the scenario I mentioned yesterday, I actually made the javascript call from code-behind work ( the alert('hello') displayed when I click the appointment ).

For cleaner presentation, I added a RADAjaxManager where the RADScheduler is among the managed controls. Now when I run the application, this time the javascript didn't work. The AppointmentClick event was still fired but the script did not execute. :(

Does this mean that no javascript may be executed when the telerik controls are ajaxified?

On the other hand, just so I could try making the script work, I removed the RADAjaxManager. I have the aspx code below.


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXEnabledWebApplication1._Default" %>  
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>  
 
<!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 runat="server">  
    <title>Untitled Page</title>  
</head>  
<body>  
    <script type="text/javascript">  
        function ShowWindow()  
        {  
            window.radopen("http://www.google.com","RadWindow1");  
        }  
    </script>  
      
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" />  
        <telerik:RadScheduler ID="RadScheduler1" runat="server" AllowDelete="False" AllowInsert="False" OnAppointmentClick="RadScheduler1_AppointmentClick" ReadOnly="True" OnAppointmentCreated="RadScheduler1_AppointmentCreated">  
              
        </telerik:RadScheduler>  
    <div>  
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
            <Windows>  
                <telerik:RadWindow ID="RadWindow1" runat="server">  
                </telerik:RadWindow>  
            </Windows>  
        </telerik:RadWindowManager>  
          
        <%--<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" 
            Width="75px">  
            <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' originalAttribute="src" originalPath="<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>" originalAttribute="src" originalPath="<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>"  
                style="border: 0px;" />  
        </telerik:RadAjaxLoadingPanel>  
          
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings>  
                <telerik:AjaxSetting  AjaxControlID="RadScheduler1">  
                    <UpdatedControls>  
                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1"/>  
                    </UpdatedControls>  
                </telerik:AjaxSetting>  
            </AjaxSettings>  
              
        </telerik:RadAjaxManager>--%>  
    </div>  
    </form>  
</body>  
</html>  
 


Then I have my code-behind:
using System;  
using System.Data;  
using System.Configuration;  
using System.Collections;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
using System.Data.SqlClient;  
 
namespace AJAXEnabledWebApplication1  
{  
    public partial class _Default : System.Web.UI.Page  
    {  
        DataTable dtReports = new DataTable();  
 
        protected void Page_Load(object sender, EventArgs e)  
        {  
            GetDataSource();  
 
            RadScheduler1.DataSource = dtReports;  
            RadScheduler1.DataKeyField = "EventID";  
            RadScheduler1.DataSubjectField = "EventSubject";  
            RadScheduler1.DataStartField = "StartTime";  
            RadScheduler1.DataEndField = "EndTime";  
 
            RadScheduler1.DataBind();  
 
            RadScheduler1.SelectedDate = Convert.ToDateTime("07/04/2008");  
        }  
 
        private void GetDataSource()  
        {  
 
            ...retrieves the data source..          
        }  
 
        protected void RadScheduler1_AppointmentClick(object sender, Telerik.Web.UI.SchedulerEventArgs e)  
        {  
            String script = "<script type=\"text/javascript\">ShowWindow();</script>";  
            //String script = "<script type=\"text/javascript\">alert('hello');</script>";  
 
            this.Page.RegisterClientScriptBlock("TestWindow", script);  
        }  
 
        protected void RadScheduler1_AppointmentCreated(object sender, Telerik.Web.UI.AppointmentCreatedEventArgs e)  
        {  
            e.Appointment.ToolTip = "Event ID - " + Convert.ToString(e.Appointment.ID);  
        }  
    }  
}  
 

The alert() works well. But when I try to call ShowWindow() which attempts to call window.radopen(), the VS 2005 debugger says 'Microsoft JScript runtime error: Object doesn't support this property or method'.

Am I missing anything in the aspx file? The Telerik.Web.UI dll has already been registered as reference. I really hope you could help me with this... Thank you very much!
0
Simon
Telerik team
answered on 10 Jul 2008, 01:35 PM
Hello Paula Bianca,

Thank you for providing the code.

The script registered in the AppointmentClick routine does not execute after the AJAX request. How to properly execute JavaScript after an AJAX request you need to use the ResponseScripts collection of RadAjaxManager and register the script there, like this:

    protected void RadScheduler1_AppointmentClick(object sender, Telerik.Web.UI.SchedulerEventArgs e) 
    { 
        ... 
 
        this.RadAjaxManager1.ResponseScripts.Add("ShowWindow();"); 
    } 

More information on the matter you can find here.


The error you receive when you remove the RadAjaxManager is due to the fact that when the ShowWindow function is executed the RadWindowManager and its Windows are not completely initialized and they do not actually exist.

You can workaround the problem by registering the script shown below instead:

String script = "<script type=\"text/javascript\">function pageLoad(ShowWindow());</script>"

In this way you will ensure the the ShowWindow function is called after all client-side objects are initialized, hence the error will not appear and everything will work normally.

Greetings,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Neerav
Top achievements
Rank 1
answered on 11 Dec 2010, 01:37 PM
Hello Telerik Staff

I am tyring to create same scenrio as provided in attached screen shots (figure1, figrue 2, figure3).
First kindly let me know as to how to go for this.
---------------------------------------------------------------------
However after going through the different forums, I have able to reach upto a stage where I am able to bind the radgrid through datasource on button click. The grid gets displayed in a new radwindow.
After click on button I am using ClientScript.registerstartup method for calling javascript function in which the code for opening radwindow is written(radopen()).
Please find attached the sample I have created which is similar to existing application.
The problem is, when I click button, the whole page gets refeshed and then the grid gets dsiplayed in new window.
But if put button and radgrid in ajax, the grid gets displayed as white page i.e. without any data. The same gets OK when I do not ajaxify them.
Kinly let me know, where I am going wrong since I have to use ajax on button click so that the page does not gets refreshed.
Also it would be appreciated if you let me know as if I am going right direction or not, to achieve the attached screen shot (figure 1, figure 2, figure 3)scenario.

following is my .cs  code

 

 

protected void Page_Load(object sender, EventArgs e)
{}

 

 

 

protected void RadButton1_Click(object sender, EventArgs e)
{

 

 

 

ArrayList sourcelist2 = new ArrayList();

 

 

 

//sourcelist2.Add(new TestListItem("Item 2", 1));

 

 

 

//sourcelist2.Add("testing");

 

sourcelist2.Add(

 

new TestListItem("Item 2", 1));

 

sourcelist2.Add(

 

new TestListItem("Item 2", 2));

 

sourcelist2.Add(

 

new TestListItem("Item 2", 3));

 

sourcelist2.Add(

 

new TestListItem("Item 2", 4));

 

sourcelist2.Add(

 

new TestListItem("Item 2", 5));

 

sourcelist2.Add(

 

new TestListItem("Item 2", 6));

 

 

 

this.RadGrid2.DataSource = sourcelist2;

 

RadGrid2.DataBind();

 

 

string script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(makewin1);</script>";

 

ClientScript.RegisterStartupScript(

 

this.GetType(), "showWindoww", script);

 

 

 

this.radAjax.ResponseScripts.Add("makewin1();");

 

}

Following is my makewin1() code

 

 

function makewin1() {

 

alert(

 

"Entered2");

 

 

 

var oWndtest = radopen("Default.aspx", "makeradwin");// makeradwin is radwindow with radgrid2 as content template

 

 

}

Following is ajax setting

<

 

 

telerik:AjaxSetting AjaxControlID="RadButton1"> // RadButton1 is button ID

 

 

 

<UpdatedControls>

 

 

 

 

<telerik:AjaxUpdatedControl ControlID="RadGrid2" />

 

 

 

 

</UpdatedControls>

 

 

 

</telerik:AjaxSetting>
----------------------------------------------------------------------------------------

Thanks and Regards

Tags
Scheduler
Asked by
Paula Bianca
Top achievements
Rank 1
Answers by
Simon
Telerik team
Paula Bianca
Top achievements
Rank 1
Neerav
Top achievements
Rank 1
Share this question
or