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

RadDatePicker+ajax

4 Answers 109 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
lnu
Top achievements
Rank 1
lnu asked on 24 Nov 2009, 02:33 PM
Hello,

I'm creating dynamically some web users controls which contains a RadDatePicker. I'm using the DayRender event to disallow weekend selection. When doing full postback everything works fine, but If I use ajax(AjaxPanel or AjaxManager) I can select the weekend.

sample:
 <telerik:RadAjaxPanel runat="server" ID="panel1"
         <telerik:RadDatePicker runat="server" Visible="false" ID="dp1"
         <Calendar OnDayRender="dayRender"></Calendar> 
         </telerik:RadDatePicker> 
         <asp:Button runat="server" ID="btn1" OnClick="btn1_Click" /> 
</telerik:RadAjaxPanel> 
 protected void btn1_Click(object sender, EventArgs e) 
        { 
            dp1.Visible = true
        } 
         
        protected void dayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) 
        { 
            if (e.Day.IsWeekend) 
            { 
                e.Day.IsSelectable = false
                dp1.Calendar.SpecialDays.Add(e.Day); 
            } 
        } 

Am I missing something?

Best regards,

Laurent

4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 25 Nov 2009, 12:35 PM
Hi lnu,

For more information about how to use ajax with user controls, please review the following articles:
RadAjax and WebUserControls
Loading User Controls
Help topic

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
lnu
Top achievements
Rank 1
answered on 25 Nov 2009, 12:55 PM
I don't think the answer matches the question.

to be clearer.

I take your sample http://demos.telerik.com/aspnet-ajax/ajax/examples/common/showingwebcontrols/defaultcs.aspx.
I add a dayrender events to disallow weekend selection of the radcalendar1. You still can click on the weekend. On the opposite, if you remove the radajaxmanager, it works as expected.

 <telerik:RadCalendar ID="RadCalendar1" runat="server" EnableMultiSelect="false" Visible="false" AutoPostBack="true" OnSelectionChanged="RadCalendar1_SelectionChanged" OnDayRender="dayRender" /> 



protected void dayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) 
        { 
            if (e.Day.IsWeekend) 
            { 
                e.Day.IsSelectable = false
                e.Day.IsDisabled = true
                RadCalendar1.SpecialDays.Add(e.Day); 
            } 
        } 


Could you have a try and tell me if I'm wrong?
0
lnu
Top achievements
Rank 1
answered on 15 Jan 2010, 10:31 AM
Hello,

I'm still stuck. None of your links match the problem here.
In fact, the datepicker is added dynamically on a button click registered in a radajaxmanager.
The point is the "DescribeComponent" method of the calendar is called before the dayrender event.
The days added to the specialddays collection in the dayrender event are never written.
 In a non ajax scenarion, everything works as expected but in the ajax scenario the ProxyScriptControl comes around and calls the describecomponent method of each child, and thus my calendar.

Do you have a workaround for this case?

Best regards,

Laurent
0
Pavlina
Telerik team
answered on 19 Jan 2010, 03:52 PM
Hi lnu,

I tested the provided code and disabling weekend selection of the RadCalendar1 is not working properly even if I set EnableAJAX property of RadAjaxManager to false.

However I suggest you examine this code library which elaborates on this subject and let me know if it helps.

Greetings,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Calendar
Asked by
lnu
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
lnu
Top achievements
Rank 1
Share this question
or