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

[Solved] Master Page, AjaxManager, RadScheduler

5 Answers 284 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 11 Feb 2008, 09:41 PM

I have a master page which contains a RadAjaxManager and a RadScriptManager.  My child page contains a RadScheduler which I'm trying to ajaxify.  Basically, when the user clicks on a day, I want to schedule the appointment with no input from the user and then show that appointment on the scheduler with no refresh.  The appointment doesn't show up without a refresh, though, even though I can see the data source is updated.

(All Q307 Promotheus controls, by the way.)

I'm programmatically finding the RadAjaxManager in the page load of the child page and loading the setting by using the AddAjaxSetting method.  If I don't use a master page and set the Ajax Settings during design time, it works.

I put together this simple form to show the problem.  Here is the code-behind:

public partial class SchedulerTest : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        RadAjaxManager RadAjaxManager1 = (RadAjaxManager)this.Page.Master.FindControl("RadAjaxManager1");

        RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadAjaxManager1, this.RadScheduler1);

        RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadAjaxManager1, RadAjaxManager1);

        RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadScheduler1, RadScheduler1);

        RadAjaxManager1.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(this.RadAjaxManager1_CustomAjaxRequest);

        if (!IsPostBack)

        {

            this.RadScheduler1.DataSource = LoadAppointments();

            RadScheduler1.DataKeyField = "id";

            RadScheduler1.DataEndField = "end";

            RadScheduler1.DataStartField = "start";

            RadScheduler1.DataSubjectField = "subject";

            RadScheduler1.DataBind();       

        }

    }

    List<SchedulerApptInfo> LoadAppointments()

    {

        SchedulerApptInfo sched = new SchedulerApptInfo();

        sched.ID = "1";

        sched.Start = DateTime.Now;

        sched.End = DateTime.Now.AddDays(1);

        sched.Subject = "First Appt.";

        SchedulerApptInfo sched2 = new SchedulerApptInfo();

        sched2.ID = "2";

        sched2.Start = DateTime.Now.AddDays(2);

        sched2.End = DateTime.Now.AddDays(3);

        sched2.Subject = "Second Appt.";

        List<SchedulerApptInfo> schedList = new List<SchedulerApptInfo>();

        schedList.Add(sched);

        schedList.Add(sched2);

        return schedList;

    }

    protected void RadAjaxManager1_CustomAjaxRequest(object sender, AjaxRequestEventArgs e)

    {

        if (e.Argument == "Inserting")

        {

            SchedulerApptInfo sched = new SchedulerApptInfo();

            sched.ID = "3";

            sched.Start = DateTime.Now.AddDays(4);

            sched.End = DateTime.Now.AddDays(4.5);

            sched.Subject = "Third Appt.";

            List<SchedulerApptInfo> schedList = new List<SchedulerApptInfo>();

            schedList.Add(sched);

            this.RadScheduler1.DataSource = schedList;

            RadScheduler1.DataKeyField = "id";

            RadScheduler1.DataEndField = "end";

            RadScheduler1.DataStartField = "start";

            RadScheduler1.DataSubjectField = "subject";

            RadScheduler1.DataBind();

            RadScheduler1.Rebind();

        }

    }

}


And the design:

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

    <script language="javascript" type="text/javascript">

            function AppointmentInserting(sender, eventArgs)

            {             

                var reqeuestString = "Inserting";

                var ajaxManager = <%= this.Master.FindControl("RadAjaxManager1").ClientID %>;

                ajaxManager.AjaxRequest(reqeuestString); 

                eventArgs.set_cancel(true);

            }          

            function formatFullDate(date)

            {

                var year = padNumber(date.getUTCFullYear(), 4);

                var month = padNumber(date.getUTCMonth() + 1, 2);

                var day = padNumber(date.getUTCDate(), 2);

                var hour = padNumber(date.getUTCHours(), 2);

                var minute = padNumber(date.getUTCMinutes(), 2);                

                return year + month + day + hour + minute;

            }            

    </script>

</telerik:RadScriptBlock>

<telerik:RadScheduler ID="RadScheduler1" runat="server" SelectedView="MonthView" OnClientAppointmentInserting="AppointmentInserting">

</telerik:RadScheduler>

</asp:Content>

What am I missing?

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 13 Feb 2008, 12:17 PM
Hi Brad,

Using RadAjax in master pages is a special scenario and requires a more specific approach. We have online demos which will help you get started:

Master pages - RadAjax "Prometheus" for ASP.NET

AJAX Manager in Master Page - Classic

Should you have further questions, please feel free to ask us.


All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brad
Top achievements
Rank 1
answered on 13 Feb 2008, 02:45 PM

Thanks, Peter. The demos did help me get started, but unfortunately the demos don’t mention the scenario I outlined above.  It is my understanding, after reading many forum posts, that the RadAjaxManagerProxy can not be accessed in client side javascript.

In my situation I need to handle the AppointmentInserting client side event of the RadScheduler (on the child page), send off an AjaxRequest to update the data source, then rebind the scheduler with the updated data.  I followed this post’s suggestion of getting a reference to the RadAjaxManager on the master page and adding the ajaxified controls in the code behind file, but the RadScheduler does not update unless I manually refresh.  

http://www.telerik.com/community/forums/thread/b311D-baaeat.aspx

<EDIT>
By the way, I can achieve the desired result if I put these settings in the Master Page:

<radA:AjaxSetting AjaxControlID="MainContent">

    <UpdatedControls>

        <radA:AjaxUpdatedControl ControlID="MainContent" />

    </UpdatedControls>

</radA:AjaxSetting>

MainContent = ContentPlaceHolder.  But this is not ideal, of course, because I don't want to re-render every control in the ContentPlaceHolder.
</EDIT>

Any other suggestions? 

Thanks! 
Brad
0
Peter
Telerik team
answered on 14 Feb 2008, 02:41 PM
Hello Brad,

There is a very good discussion in this forum thread, which is related to what you need to achieve. Please, review the thread and let us know if you have questions or need further assistance.



Cheers,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Brad
Top achievements
Rank 1
answered on 14 Feb 2008, 05:16 PM

Thanks, Peter, but I had checked out that forum already, too.

I finally figured out my problem, though, and it had to do with the master page.  I created a new master page and everything worked fine.  I compared the two master pages and noticed in my original master page the <head> tag did not include the runat="server" attribute.  I stuck that in the tag and it’s working fine now.

0
Peter
Telerik team
answered on 15 Feb 2008, 02:40 PM
Hi Brad,

Greate! Thanks for sharing your findings with us.

All the best,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
Brad
Top achievements
Rank 1
Answers by
Peter
Telerik team
Brad
Top achievements
Rank 1
Share this question
or