By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,665 Members | 1,900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,665 IT Pros & Developers. It's quick & easy.

Calendar Help in ASP.NET 2.0

P: n/a
Hello,

I have a calendar and a textbox right below it on my webpage. I need
help with creating some code to display information about the date the
user clicked in the text box below it.

For example, they clock on August 13th, and in texbox1, it will say
"Wedding, 2:00 PM".

How do I get started?

Thanks,
Brian

Sep 14 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Brian,

I'm not sure what you need to accomplish, but you seem to need to look up
additional information based on the date. Perhaps you can provide more info?

In the meantime, I've pasted in a little code that might get you started
towards something....

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Calendar1_SelectionChanged _
(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Text = _
GetAdditionalData(Calendar1.SelectedDate)
End Sub

Function GetAdditionalData _
(ByVal selDate As DateTime) As String
If selDate.DayOfWeek = DayOfWeek.Saturday Or _
selDate.DayOfWeek = DayOfWeek.Sunday Then
Return "Weekend Date: " & _
selDate.ToLongDateString
Else
Return "Week day Date: " & _
selDate.ToLongDateString
End If
End Function
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Calendar Value in a Textbox</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:calendar id="Calendar1" runat="server"
onselectionchanged="Calendar1_SelectionChanged"></asp:calendar>
<br />
<asp:textbox id="TextBox1" runat="server"
width="300px"></asp:textbox>&nbsp;</div>
</form>
</body>
</html>

<br**********@gmail.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
Hello,

I have a calendar and a textbox right below it on my webpage. I need
help with creating some code to display information about the date the
user clicked in the text box below it.

For example, they clock on August 13th, and in texbox1, it will say
"Wedding, 2:00 PM".

How do I get started?

Thanks,
Brian

Sep 15 '06 #2

P: n/a
I hope this is clearer:

I have a calendar on my page with a textbox below it. When a user
clicks on a date, I want to be able to show events for that day in the
textbox below the calendar.

For example, they click on September 21st, I want it to display
information for events of that day in the textbox below. And maybe even
appear as a tooltip?

I will look at your code too but what I stated above is my goal.

Ken Cox [Microsoft MVP] wrote:
Hi Brian,

I'm not sure what you need to accomplish, but you seem to need to look up
additional information based on the date. Perhaps you can provide more info?

In the meantime, I've pasted in a little code that might get you started
towards something....

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Calendar1_SelectionChanged _
(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Text = _
GetAdditionalData(Calendar1.SelectedDate)
End Sub

Function GetAdditionalData _
(ByVal selDate As DateTime) As String
If selDate.DayOfWeek = DayOfWeek.Saturday Or _
selDate.DayOfWeek = DayOfWeek.Sunday Then
Return "Weekend Date: " & _
selDate.ToLongDateString
Else
Return "Week day Date: " & _
selDate.ToLongDateString
End If
End Function
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Calendar Value in a Textbox</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:calendar id="Calendar1" runat="server"
onselectionchanged="Calendar1_SelectionChanged"></asp:calendar>
<br />
<asp:textbox id="TextBox1" runat="server"
width="300px"></asp:textbox>&nbsp;</div>
</form>
</body>
</html>

<br**********@gmail.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
Hello,

I have a calendar and a textbox right below it on my webpage. I need
help with creating some code to display information about the date the
user clicked in the text box below it.

For example, they clock on August 13th, and in texbox1, it will say
"Wedding, 2:00 PM".

How do I get started?

Thanks,
Brian
Sep 15 '06 #3

P: n/a
If you're looking for hooking up events to a database, to show in the
calendar - - here's a code sample from ASPNet101.com that might help:
http://aspnet101.com/aspnet101/aspne...code=caltitles

there are others - just search in the website for 'calendar'

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

<br**********@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
I hope this is clearer:

I have a calendar on my page with a textbox below it. When a user
clicks on a date, I want to be able to show events for that day in the
textbox below the calendar.

For example, they click on September 21st, I want it to display
information for events of that day in the textbox below. And maybe even
appear as a tooltip?

I will look at your code too but what I stated above is my goal.

Ken Cox [Microsoft MVP] wrote:
Hi Brian,

I'm not sure what you need to accomplish, but you seem to need to look
up
additional information based on the date. Perhaps you can provide more
info?

In the meantime, I've pasted in a little code that might get you started
towards something....

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Calendar1_SelectionChanged _
(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Text = _
GetAdditionalData(Calendar1.SelectedDate)
End Sub

Function GetAdditionalData _
(ByVal selDate As DateTime) As String
If selDate.DayOfWeek = DayOfWeek.Saturday Or _
selDate.DayOfWeek = DayOfWeek.Sunday Then
Return "Weekend Date: " & _
selDate.ToLongDateString
Else
Return "Week day Date: " & _
selDate.ToLongDateString
End If
End Function
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Calendar Value in a Textbox</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:calendar id="Calendar1" runat="server"
onselectionchanged="Calendar1_SelectionChanged"></asp:calendar>
<br />
<asp:textbox id="TextBox1" runat="server"
width="300px"></asp:textbox>&nbsp;</div>
</form>
</body>
</html>

<br**********@gmail.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.com...
Hello,
>
I have a calendar and a textbox right below it on my webpage. I need
help with creating some code to display information about the date the
user clicked in the text box below it.
>
For example, they clock on August 13th, and in texbox1, it will say
"Wedding, 2:00 PM".
>
How do I get started?
>
Thanks,
Brian
>

Sep 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.