I am in the process of changing WebCalendar to WebExplorerBar , in order to migrate to 11.2 and although I can use get_selectedDate() client side to return the select date, I am unable to set the initial date to be other than "today" either by setting
SelectedDate or get_selectedDate() or otherwise.
Can someone suggest how this can be done either in the controls client initialize event or page load etc.
Thanks.
Hi jcad,
check out this forum post: http://community.infragistics.com/forums/p/57030/291439.aspx#it seems to be the same issue.
Thanks but I think the problem is due to the control needing to be in webpanel in order for it to update. I now have it working properly in a webpanel. However I want to avoid using a webpanel with it being an "old (non 11.2) control. Should I be able to use it within a WebExplorerBar (as per the one on one replacement guide?) Does anyone have an example of it being used this way?
What's happen when it is inside WebExplorerBar, it should be working in the same way?
use FindControl to get refence of the WebMonthCalendar
<ig:WebExplorerBar ID="WebExplorerBar1" runat="server" Width="250px" GroupContentsHeight=""> <Groups> <ig:ExplorerBarGroup GroupContentsHeight="" Text="Group"> <Items> <ig:ExplorerBarItem> <Template> <ig:WebMonthCalendar ID="WebMonthCalendar1" runat="server"> <ClientEvents Initialize="WebMonthCalendar1_Initialize" /> </ig:WebMonthCalendar> </Template> </ig:ExplorerBarItem> </Items> </ig:ExplorerBarGroup> <ig:ExplorerBarGroup GroupContentsHeight="" Text="Group"> </ig:ExplorerBarGroup> </Groups> </ig:WebExplorerBar>
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DateTime dt = DateTime.Now; DateTime startDate = DateTimeHelper.StartOfWeek(dt, DayOfWeek.Monday); DateTime endDate = DateTimeHelper.EndOfWeek(dt, DayOfWeek.Sunday); WebMonthCalendar wmc = (WebMonthCalendar)WebExplorerBar1.Groups[0].Items[0].FindControl("WebMonthCalendar1"); wmc.SelectedDates.RangeMin = startDate; wmc.SelectedDates.RangeMax = endDate; } } public static class DateTimeHelper { public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek) { int diff = dt.DayOfWeek - startOfWeek; if (diff < 0) { diff += 7; } return dt.AddDays(-1 * diff).Date; } public static DateTime EndOfWeek(this DateTime dt, DayOfWeek endOfWeek) { int diff = endOfWeek - dt.DayOfWeek; if (diff < 0) { diff += 7; } return dt.AddDays(diff).Date; } }
I suspect the problem might have been caused by trying to use the calendar control (within a webexplorerbar) in a pop-up dialog. Although this worked fine with the old WebCalendar, I understand it is not best practice to have anything interactive in a dialog. EIther way we are now working through our application replacing the pop-up dialogs with having the webdatepicker on the original page.
Regards.