basic difference between OnSelectionChanged & OnDayRender of <asp:Calendar> - asp.net

What is the basic difference between OnSelectionChanged & OnDayRender of <asp:Calendar>
Instead of down-voting please try to answer my question as in future this will be useful for the new programmers like me.
thank you.

SelectionChanged is an event which is triggered when the User has selected a day, a week, or an entire month by clicking the date selector controls.
DayRender is an event which is triggered when ASP.NET has rendered a day of the calendar on serverside.
The DayRender event is raised when each date cell in the Calendar
control is created. You can control the contents and formatting of a
date cell when it is created by providing code in the event handler
for the DayRender event.

Related

asp.net calendar extender postback

Hello guys i been using asp.net calendars for giving the user filtering options over a grid table.
Now i decided to try the ajax extender to save some room on the page.
The moment the user clicks on one of the calendars the grid updates/changes ( i got some code in the SelectionChanged of the calendars that after few rows gives 2 date values that are sent to the sql and used as the allowed date range for the filter/select command ).
Now my problem is that unlike the regular calendar the ajax extender got no postback and no selectionchanged event i can use code in , and i not so sure how to make it all work without those 2 options.
The calendar extender "extends" your control. You still use your control's events. The extender will basically "impersonate" a user typing text into the control...
Catch the events on the control that the extender is bound to, not the extender itself.

Disable dates conditionally with Asp.net Ajax Calendar Extender

If you have used Calendar Extender, i am looking for ways to disable dates based on selection from another calendar selected date. In a project management application there are end and start dates, i am looking for ways to validate these on client. Someways would require postback which i am not willing to perform. There seems to be StartDate and EndDate properties for the calendar on the server, but does not seem to have any client side counterparts. Have you got any ideas how i can perform this.
I know it's too late to reply this post but it my help someone
Disable dates in Ajax Calendar Extender with different dates examples
You can overwrite _cell_onclick javascript event to show an alert if a wrong date is chosen depending on the selected date in the other calendar.
Here is an example: Ajaxtoolkit Calendar Extender close button and date restriction

AutoPostBack using ASP.NET text box and AjaxControlToolkit CalendarExtender

I would like to like to trigger a postback after user selects a date. Am using the AjaxControlToolkit's CalendarExtender control. The date textbox which is associated to the extender is editable too which enables the user to manually enter the date in a particular format. Values of quite a few controls which reside on that page are to be updated depending on the newly selected date and hence going to the server is a must.
I did try using the OnClientDateSelectionChanged property of the extender which lets me hook in my custom javascript, using which i was planning to trigger a postback but for some odd reason the function gets called only if the date is selected using an extender and not when manually edited (Hoping that it doesn't catch the click event over textbox's change).
Am sure many have tackled this issue before. Please do share. Thanks.
Here it is, Keep It Simple as they say. Set AutoPostBack of the text box to true and capture the OnTextChanged event on the server side.

asp:Calendar DateClicked event (not just SelectionChanged)

I am using the standard asp:Calendar control. When a user clicks a date, I am showing a modal popup by handling the SelectionChanged event.
However this means that nothing happens if the user clicks a date, then closes the popup, then clicks the same date again.
I'd rather be handling a DateClick event, and do away with the concept of having a selected date altogether.
Can this be achieved using the asp:Calendar?
Found a workaround:
In the SelectionChanged event handler, just call
calendar.SelectedDates.Clear();
I had a similar problem - I solved it by preventing the user from selecting the currently selected date. I put the following in the DayRender event:
If e.Day.Date = DateValue(calCalendar.SelectedDate) Then
e.Day.IsSelectable = False
End If

How best to make the selected date of an ASP.NET Calendar control available to JavaScript?

How best to make the selected date of an ASP.NET Calendar control available to JavaScript?
Most controls are pretty simple, but the calendar requires more than just a simple document.getElementById().value.
When you click on a date with the calendar, ASP does a postback, you could always put the SelectedDate value of the calendar control into a hidden field on the page during the OnLoad event of the page or the SelectionChanged event of the Calendar control.
This might help you. It uses YUI, but you can probably port some of that functionality over to another library or custom code it. It should get you started though.
http://www.codeproject.com/KB/aspnet/aspnet-yahoouicalendar.aspx
You might find useful the MS AJAX Calendar control extender, you can get the date just by
document.getElementById('<%= DateTextBox.ClientID%>').value;
DateTextBox is an asp:TextBox control that will be extended with the AJAX calendar.
I'm using Page.ClientScript.RegisterClientScriptBlock() to put a small script on the page that just declare a variable with the desired value. I was hoping for some a little less... clunky.

Resources