RadDatePicker+ajax

5 posts, 0 answers
  1. lnu
    lnu avatar
    19 posts
    Member since:
    Aug 2012

    Posted 24 Nov 2009 Link to this post

    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
  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 25 Nov 2009 Link to this post

    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.
  3. lnu
    lnu avatar
    19 posts
    Member since:
    Aug 2012

    Posted 25 Nov 2009 Link to this post

    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?
  4. lnu
    lnu avatar
    19 posts
    Member since:
    Aug 2012

    Posted 15 Jan 2010 Link to this post

    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
  5. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 19 Jan 2010 Link to this post

    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.
Back to Top