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 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 August 8th, 2003, 06:56 PM
Registered User
Join Date: Aug 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Change selecteddate for Calendar

On page 507 of Beginning ASP.Net:

<asp:Calendar id="MyCalendar" runat="server"

How can I change the hard-coded date in the sample to today's date? I've tried taking the selecteddate specification out, but then the sample uses a date of 1/1/0001 ("No Events Scheduled For Monday, January 01, 0001"), although the calendar displays today's date.

I've tried using variables to no avail (when declaring variables and assigning to calendar.selecteddate in page sub_load, says "calendar is not declared" and won't allow me to use code blocks within a server tag) Can anyone help? TIA!

BTW, here's a code snippet with the above in context...

Protected Sub ShowDailyEvents()
    Dim dataSet As DataSet = LoadMyCalendarData()
    If dataSet is Nothing then
        Exit Sub
    End If
    'bind to repeater control
    Dim eventsForToday As DataSet
    eventsForToday= GetEventsDataSet (dataSet, MyCalendar.SelectedDate)
    If (eventsForToday.Tables(0).Rows.Count > 0) Then
        DailyDetailsPanel.Visible = True
        SelectedDate.Text = "Events For " + MyCalendar.SelectedDate.ToLongDateString()
        DailyDetailsPanel.Visible = False
        SelectedDate.Text = "No Events Scheduled For " + MyCalendar.SelectedDate.ToLongDateString()
    End if
End sub
<asp:Calendar id="MyCalendar" runat="server"

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

I had a hard time finding a solution to this as well, though I was using C#. Try this link for a more detailed explanation of how to do it...


[Visual Basic]
<%@ Page Language="VB" AutoEventWireup="True" %>


   <script language="VB" runat="server">

        Sub Selection_Change(sender As Object, e As EventArgs)
            Calendar1.TodaysDate = Calendar1.SelectedDate
            Label1.Text = "Today's Date is now " & Calendar1.TodaysDate.ToShortDateString()
        End Sub 'Selection_Change



   <form runat="server">

      <h3>Calendar Example</h3>

      Select a date on the Calendar control to use as today's date.<br><br>

      <asp:Calendar ID="Calendar1" runat="server"

         <SelectedDayStyle BackColor="Yellow"



      <asp:Label id="Label1" runat=server />


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
Calendar like calendar in AJAX in ASP.NET h@ckerz ASP.NET 2.0 Professional 0 February 19th, 2008 12:56 AM
Calendar.SelectedDate and clearing it Quick209 ASP.NET 2.0 Professional 1 January 12th, 2007 02:17 PM
ie calendar gefuller2510 BOOK: CSS Instant Results 3 January 3rd, 2007 07:31 PM
calendar trangd Beginning PHP 2 June 1st, 2004 04:36 PM
Calendar kekohchaa VS.NET 2002/2003 4 April 7th, 2004 05:41 AM

All times are GMT -4. The time now is 08:13 AM.

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