Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: Beginning ASP.NET 1.0
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 26th, 2004, 05:14 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch. 14 Calendar Modification

Hi,


I've been attempting to modify the calendar example to have it automatically bring up a calendar based on the current date (instead of having to specify a specific date such as: 2004/01/26).

Here's a quick piece of code:

<asp:Calendar id="MyCalendar" runat="server"
            SelectedDate= "2004/01/26"
            VisibleDate= "2004/01/26"
            FirstDayOfWeek="Monday"
            ...

I've been attempting to use functions such as Date() and Now() in place of specified values, but I'm receiving a parser error stating that the functions are not valid values of DateTime.

Any help would be greatly appreciated.

  #2 (permalink)  
Old January 27th, 2004, 10:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

My guess is that you need to use American dates. American dates are Month/Day/Year

in example - 01/26/2004 = January 26th, 2004.

  #3 (permalink)  
Old January 27th, 2004, 02:45 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, if I want to specify a date to bring up, using the format 2004/01/26 works just fine. What I'm trying to do is eliminate that entire string and have it bring up the calendar based upon system date.

Thus, instead of:
...
SelectedDate="2004/01/26"
VisibleDate="2004/01/26"
...

I want to use something like:
...
SelectedDate=Now()
VisibleDate=Now()
...

But I can't get the syntax quite right, and that's what I've been struggling with.

  #4 (permalink)  
Old January 29th, 2004, 10:00 PM
Registered User
 
Join Date: Jan 2004
Location: Orlando, FL, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I can not believe that no one has answered your problem yet (I am assuming VB.NET). I am used to the Wrox chat groups being much faster than this?

On the page load sub routine, just put this in:

Dim dt As DateTime = DateTime.Now
Dim format As [String] = "yyyy/MM/dd"
Dim strDate As [String] = dt.ToString(format)

MyCalendar.SelectedDate = strDate

I was interested in your subject, because this is exactly why I came here, I tried to get the C# example to work, but I am getting an error on the:

MyCalendar.SelectedDate = strDate;

line. It says that it can not convert a string to date. So I tried a date, still did not work.

Hopefully someone can help????
  #5 (permalink)  
Old February 2nd, 2004, 05:28 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help. That worked perfectly.

  #6 (permalink)  
Old February 2nd, 2004, 06:45 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, as usual, you fix one problem and another arises. The calendar loads up with the correct date (i.e. it will show the calendar for February 2004), but the string below that lists if there are or are not events scheduled for that day, it gives a date of January 01, 0001. If I select a different date from that point, it works perfectly. If I try and go back to today's date (eg. February 2, 2004), it doesn't load up the events for that date.

Any ideas anyone?

  #7 (permalink)  
Old December 1st, 2004, 06:23 PM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

roncalw,

I had the same problem myself. I was trying to get it to work in C#. An example of how to to this in VB and C# can be found at the following link...

http://msdn.microsoft.com/library/de...sDateTopic.asp

PLease note that the C# example here did not work for me. I got errors about "ticks". So instead, I did the following which did work...

<script runat="server">
    void Page_Load(){
        Calendar1.SelectedDate = DateTime.Today;
        /*Calendar1.TodaysDate = Calendar1.SelectedDate;*/
    }
</script>

Good Luck,

--Phil
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 14 Calendar Control sajhak ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2006 12:11 PM
Chapter 14 Calendar webrobb BOOK: Beginning ASP.NET 1.0 7 August 28th, 2006 03:59 AM
ch.14 file errors caseyc BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 10 February 28th, 2006 03:59 PM
CH. 14 Stored Procedure mcauliff BOOK: Beginning ASP 3.0 1 October 4th, 2005 01:52 PM
Lesson on Event Calendar - Chapter 14 Mike Smith BOOK: Professional C#, 2nd and 3rd Editions 6 April 6th, 2004 03:03 PM



All times are GMT -4. The time now is 01:27 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.