?
Solved

Calendar.SelectedDate / VisibleDate - ASP.Net 2.0

Posted on 2006-07-04
4
Medium Priority
?
2,027 Views
Last Modified: 2010-08-05
Hi,

OK, this is probably really simple, but for some reason it just does not want to work. In ASP.Net 1.1 I used to place Calendar controls on a page, then set today's date as the selected date on page load. The calendar control would then display today as the selected date.

In ASP.Net 2.0 this does not seem to work. I have the following control declared:

                <asp:Calendar ID="calTimesheetDate" runat="server" SelectionMode="Day" ShowGridLines="true">
                    <SelectedDayStyle BackColor="Yellow" ForeColor="Red" />
                </asp:Calendar>

On Page_Load I do the following:

                calTimesheetDate.SelectedDate = DateTime.Now;
                calTimesheetDate.VisibleDate = DateTime.Now;

However even though this does actually select the date of the control in memory, i.e. if I get the date from the control somewhere else on the page, it works. BUT the calendar control does not show that the date is selected.

It only displays the selected date when it is clicked on.

Why is this ???
0
Comment
Question by:ttnetworks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 17035843
On Page_Load  do the following:

 calTimesheetDate.SelectedDate = Now.Date

hope it helps u :)
thanx
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 17035847
Try using DateTime.Today; rather than DateTime.Now;
0
 
LVL 5

Expert Comment

by:vinodhsomasekharan
ID: 17036602
0
 

Expert Comment

by:MailCo_Developer
ID: 23412507
The key is that the selected date needs to be in date format not date time.  So for example if you wanted to set the selected date in code behind you could do this:


Calendar.SelectedDate = CType(dtLocation.Rows(0)("Next_Due_Date"), Date).Date

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question