Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:

Recycle Bin | MMS | ManagedVsCrawledProperties |

Tuesday, October 16, 2012

Get current DayOfWeek in SharePoint:DatetimeControl:

We can get the current day of week easily by using “System.DateTime” control.

We cannot get the current Day of week using “DateTimeControl” directly but there is an option to get the day of week indirectly by using the “SelectedDate” property of SharePoint DateTimeControl.

Namespace: Microsoft.SharePoint.WebControls
DateTimeControl spDateTimeControl = new DateTimeControl();
string dayOfWeek = spDateTimeControl.SelectedDate.DayOfWeek.ToString();

If the user has not selected any date in the SharePoint DateTime control, the SelectedDate property of the SharePoint DateTime control returns current dateTime [means DateTime.Now]

DayOfWeek comparison:

if (spDateTimeControl.SelectedDate.DayOfWeek == DayOfWeek.Monday)

No comments:

Post a Comment