Live Chat Icon For mobile
Live Chat Icon

How to Programmatically change backgroundcolor of a Calendar Control using Dropdown List

Platform: ASP.NET| Category: Calendar

<asp:Calendar id='Calendar1' style='Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 48px' runat='server'></asp:Calendar>
<asp:DropDownList id='DropDownList1' style='Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 24px'
	runat='server' AutoPostBack='True'>
	<asp:ListItem Value='Red'>Red</asp:ListItem>
	<asp:ListItem Value='Green'>Green</asp:ListItem>
	<asp:ListItem Value='Blue'>Blue</asp:ListItem>


Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
	Dim colorName As String = DropDownList1.SelectedItem.Text
	Dim objBackColor As System.Drawing.Color = System.Drawing.Color.FromName(colorName)
	Calendar1.BackColor = objBackColor
End Sub


private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
	string  colorName   = DropDownList1.SelectedItem.Text;
	System.Drawing.Color objBackColor    = System.Drawing.Color.FromName(colorName);
	Calendar1.BackColor = objBackColor;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.