Calendar questions

V

VB Programmer

1. How do you change the font/forecolor of the Month name that shows up in
the calendar.
2. I am setting the SelectedDate property based on a dropdownlist. It is
selecting properly internally, but the calendar stays on the same month.
Any ideas?

Thanks!
 
K

Ken Cox [Microsoft MVP]

Hello [it would be nice to have a person's name],

1. You can set the CSSClass for the titlestyle property and then define a
style. See the code sample.

2. Don't forget to set the VisibleDate property as shown in the code samples
below.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim intCounter As Integer
For intCounter = 1 To 12
DropDownList1.Items.Add(intCounter.ToString)
Next
End If
End Sub


Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Dim dtm As DateTime
dtm = Now.AddMonths(Int(DropDownList1.SelectedItem.Text))
Calendar1.VisibleDate = dtm
Calendar1.SelectedDate = dtm
End Sub

<style>
.mytitlestyle {color:red}
</style>

<asp:dropdownlist id="DropDownList1" runat="server"
AutoPostBack="True"></asp:dropdownlist></p>
<asp:calendar id="Calendar1" runat="server">
<titlestyle cssclass="mytitlestyle"></titlestyle>
</asp:calendar>


Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto
 
V

VB Programmer

As usual your answer helps! By the way, the names Bob. :)


Ken Cox said:
Hello [it would be nice to have a person's name],

1. You can set the CSSClass for the titlestyle property and then define a
style. See the code sample.

2. Don't forget to set the VisibleDate property as shown in the code
samples below.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Dim intCounter As Integer
For intCounter = 1 To 12
DropDownList1.Items.Add(intCounter.ToString)
Next
End If
End Sub


Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Dim dtm As DateTime
dtm = Now.AddMonths(Int(DropDownList1.SelectedItem.Text))
Calendar1.VisibleDate = dtm
Calendar1.SelectedDate = dtm
End Sub

<style>
.mytitlestyle {color:red}
</style>

<asp:dropdownlist id="DropDownList1" runat="server"
AutoPostBack="True"></asp:dropdownlist></p>
<asp:calendar id="Calendar1" runat="server">
<titlestyle cssclass="mytitlestyle"></titlestyle>
</asp:calendar>


Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto

VB Programmer said:
1. How do you change the font/forecolor of the Month name that shows up
in the calendar.
2. I am setting the SelectedDate property based on a dropdownlist. It
is selecting properly internally, but the calendar stays on the same
month. Any ideas?

Thanks!
 

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

Top