Solved

Calendar.SelectedDate / VisibleDate - ASP.Net 2.0

Posted on 2006-07-04
4
2,018 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 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