Handling Postback in dynamic Radcalendar

2 posts, 0 answers
  1. Kothai
    Kothai avatar
    9 posts
    Member since:
    Jul 2013

    Posted 08 Aug 2013 Link to this post

    Hello,

    In my project I have only RadDate Picker controls  which is dynamic based on the database values, and a button control.   

    So I call the method for calculating CW in selected Index changed event of raddate picker, can this be done in client side? 

    Now the problem is, my page is full of Date picker control, on each and every date selection the page is getting posted back to the server. So how can i overcome this problem of postback since every control is dynamic. Any help would be great.

    Thanks.
  2. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 13 Aug 2013 Link to this post

    Hello Kothai,

    I suppose you mean Current Week with CW? In that case, you can use the following approach:
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
        <Calendar runat="server">
            <ClientEvents OnDateSelected="dateSelected" />
        </Calendar>
    </telerik:RadDatePicker>
    JavaScript:
    function dateSelected(sender, args) {
        var cell = $(args.get_renderDay().DomElement);
        var parentRow = $(cell.parents()[0]);
        var weekCell = $(parentRow.children()[0]);
     
        var currentWeek = parseInt(weekCell.text());
    }

    In addition, please note that the displayed week number in the calendar strongly depends on your Culture configurations since there are different rules for week specifications when using different Cultures:
    http://en.wikipedia.org/wiki/ISO_week_date

    To apply your preferred week rule, you could choose one of the following options:
    Copy Code
    protected void Page_Load(object sender, EventArgs e)
    {
        RadCalendar1.DateTimeFormat.CalendarWeekRule = System.Globalization.CalendarWeekRule.FirstDay;
        RadCalendar1.DateTimeFormat.CalendarWeekRule = System.Globalization.CalendarWeekRule.FirstFourDayWeek;
        RadCalendar1.DateTimeFormat.CalendarWeekRule = System.Globalization.CalendarWeekRule.FirstFullWeek;
    }

    Hope this helps. Please give the suggested solution a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top