Calendar Help in ASP.NET 2.0

B

brianwolters

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
 
K

Ken Cox [Microsoft MVP]

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>
 
B

brianwolters

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.
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>



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
 
D

David Wier

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/aspnet/codesample.aspx?code=caltitles

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

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.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.
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>



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top