Set "End by" on pageload

4 posts, 0 answers
  1. Mangesh
    Mangesh avatar
    16 posts
    Member since:
    Sep 2011

    Posted 10 Sep 2012 Link to this post

    Hi,

    I want to set "End by" date on pageload to next month's day. How can I do that?

    Thanks,
    Mangesh
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Sep 2012 Link to this post

    Hi Mangesh,

    Try the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadSchedulerRecurrenceEditor ID="RadSchedulerRecurrenceEditor1" runat="server">
    </telerik:RadSchedulerRecurrenceEditor>

    C#:
    protected void Page_Load(object sender, EventArgs e)
        {
            ((RadDatePicker)(RadSchedulerRecurrenceEditor1.FindControl("RangeEndDate"))).SelectedDate = (DateTime.Now.AddMonths(1));
        }

    Hope this helps.

    Regards,
    Princy.
  3. Mangesh
    Mangesh avatar
    16 posts
    Member since:
    Sep 2011

    Posted 11 Sep 2012 Link to this post

    Hi Princy,

    Thanks for the code but unfortunately it didn't work in my scenario.

    I checked the value of $('#RadSchedulerRecurrenceEditor1_RangeEndDate_dateInput') after setting to the next month and in Mozilla debugger it is clearly showing next month's value, however in the End Day input box, it is still showing current date.
    I have attached the screenshots.

    I also checked for any other JavaScript error in console but there were no error.

    -
    Mangesh
  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2035 posts

    Posted 11 Sep 2012 Link to this post

    Hello,

    I suggest you to use the OnClientFormCreated client-side event  instead of server-side events to modify the Advanced Form. Here you can find more information about customizing the Advanced From using jQuery and css. Here below I am providing an implementation of your desired functionality:
    //aspx

    <telerik:RadScheduler runat="server" ID="RadScheduler1" AdvancedForm-Modal="true" OnClientFormCreated="OnClientFormCreated">         
        </telerik:RadScheduler>

    //JavaScript

    function OnClientFormCreated(sender, args) {
        var $ = $telerik.$;
        var mode = args.get_mode();
        if (mode == Telerik.Web.UI.SchedulerFormMode.AdvancedInsert || mode == Telerik.Web.UI.SchedulerFormMode.AdvancedEdit) {
            var recurrenceEditorJqueryObj = $("[id$='RangeEndDate']");
            var recurrenceEditor = $find(recurrenceEditorJqueryObj.attr("id"));
            var today = new Date();
            today.setMonth(today.getMonth() + 1);
            recurrenceEditor.set_selectedDate(today);
             
        }
     }


    Kind regards,
    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top