Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

How to get the days name in a calendar control in asp.net(c#).
for example:
when i select the week in a calendar control it should display the selected days name. such as Sunday,Monday, etc.

In my grid there are 7 text boxes are there. I want to display day of the week selection. (I have changed calendar selection to week)


Thanks and Regards,
Murali.k
Posted
Comments
Member 14193605 1-Apr-19 21:01pm    
What if I want my calender to display only tuesdays on calender using if else statement in asp.net, how would I do that?

See the solution here:
how to get Day Name from calendar control in asp.net(c#)[^]

Calendar1.SelectedDate.DayOfWeek
 
Share this answer
 
v2
C#
Calendar1.SelectedDate.DayOfWeek
 
Share this answer
 
Make a switch case for each of the possible results of
Switch(Calendar1.SelectedDate.DayOfWeek)
{
Case "0": return "Sunday" break;
Case "1": return "Monday" break;
etc
.
.
.
. 
}


0-6 and return string result as " 0= Sunday - 6 = Saturday"

have a look:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar(v=vs.80).aspx[^]
 
Share this answer
 
v2
Comments
Kmurali Krishna 4-Dec-12 4:43am    
Sorry guys I want to display the "date".
Mendor81 4-Dec-12 4:47am    
?
Kmurali Krishna 4-Dec-12 5:07am    
No need to display the "day" , I need to display the "date". Based on week selection date should be shown for every textbox (top of the every text box, I have added 7 labels for that).
Mendor81 4-Dec-12 5:18am    
I still don't get it exactly what you need. or your not explaining yourself very well in the context or i'm definitely getting old and stupid....i hope it's the first option, anyway
have tried to look at the properties of Calendar date object?
Kmurali Krishna 4-Dec-12 5:59am    
See, IN my aspx page one calendar control is there. I have changed calander contrl to week selection (calendar properties, selection MOde: DayWeek).
Based on week selection i am data is retrieving the data. That's fine. What i need is while retrieving time i want to display the "date" in label.

Ex: I have select week from 2 to 8. I want to display like this format "2-12-2012" in one label.. And second label output like this "3-12-2012".
Simple one line way of converting a day number to a day name

string dayName = Enum.GetName(typeOf(DayOfWeek), Calendar1.SelectedDate.DayOfWeek);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900