Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calendar.SelectedDate / VisibleDate - ASP.Net 2.0

Posted on 2006-07-04
4
Medium Priority
?
2,044 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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