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

Handling Postback in dynamic Radcalendar

1 Answer 83 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kothai
Top achievements
Rank 1
Kothai asked on 08 Aug 2013, 06:30 AM
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.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 13 Aug 2013, 12:13 PM
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.
Tags
Calendar
Asked by
Kothai
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or