Using version 11.1.20111.2238. I have a WebDatePicker and an associated WebMonthCalendar. If I have the auto postback SelectionChanged event set to On, it fires the WebMonthCalendar's SelectionChanged event when I click the selector arrow in the WebDatePicker. I would like this event only to fire if I actually select a new date. Is this possible? Sample WebDatePicker and WebMonthCalendar aspx code below.
<ig:WebDatePicker ID="dateEnd" runat="server" DropDownCalendarID="calendarEnd"> <AutoPostBackFlags EnterKeyDown="On" ValueChanged="On" /> </ig:WebDatePicker> <ig:WebMonthCalendar ID="calendarEnd" runat="server"> <AutoPostBackFlags SelectionChanged="On" /> </ig:WebMonthCalendar>
Hello droedger,
I followed the steps you suggested and was unable to reproduce the behavior you're describing. I created a WebDatePicker with WebMonthCalendar. I set the WebMonthCalendar's SelectionChanged="On" and tested the client-side SelectionChanged event. I noticed that the event was called only when the selected date of the calendar was changed.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using the latest Service Releases for versions 11.1.20111.2238 in NetAdvantage for .NET 2011 Volume 1, 12.2.20122.2147 in NetAdvantage for .NET 2012 Volume 2 and 13.1.20131.2045 in NetAdvantage for .NET 2013 Volume 1
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
Sincerely,
Nikila
Hi Nikila,
Thanks for the reply. Your solution works, but it ignores the built in SelectedDateChanged method (which I didn't mention in my first post). What I'm running into is that SelectionChanged="On" triggers a postback to the SelectedDateChanged method in code behind both for changing the actual date (correct) and for simply clicking the WebDatePicker's drop down arrow (the selected date has not changed so this should not happen).
Thanks, Nikila. This prompted me toward the solution - I had failed to set the date of the calendar on page load, under the mistaken assumption that the calendar's association with the WebDatePicker would automatically set the calendar's date. Adding calendarEnd.SelectedDate = dateEnd.Date to Page Load stopped the postback on first click as the calendar wasn't then attempting to set its date to match the WebDatePicker's.
Thank you for your update. I followed your steps and was able to reproduce this behavior for those times when the DatePicker's date was not getting set correctly. One way to overcome this issue would be to set the DatePicker's date in the SelectedDateChanged event handler as below:
protected void calendarEnd_SelectedDateChanged(object sender, CalendarSelectedDateChangedEventArgs e)
{
dateEnd.Date = e.NewDate;
}
Do let me know if this resolves your issue. If not, could you please send an isolated sample or modify the sample I sent earlier to demonstrate the behavior you are seeing.