ASP.NET DropDownList control in VB.NET

By using this code you can create a DropDownList control that contains items.
  • 1895

The following code explains you how to create a DropDownList control that contains five items.

Code for Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">


 <script runat="server">

    Sub SelectedItem_Change(ByVal sender As Object, ByVal e As EventArgs)

 ' Here we set the background color for days in the calender control based on the selected value in the DropDownList control.

   Calendar1.DayStyle.BackColor = _


     End Sub



    <form id="Form1" runat="server">


            DropDownList Example


        Select a background color for days in the calendar.



        <asp:Calendar ID="Calendar1" ShowGridLines="True" ShowTitle="True" runat="server" />



        <table cellpadding="5">



                    Background color:





                    <asp:DropDownList ID="DropDownListColors" AutoPostBack="True" 

                      OnSelectedIndexChanged="SelectedItem_Change" runat="server">

                        <asp:ListItem Selected="True" Value="Black"> Black /asp:ListItem>

                        <asp:ListItem Value="Green"> Green </asp:ListItem>

                        <asp:ListItem Value="Blue"> Blue </asp:ListItem>

                        <asp:ListItem Value="Silver> Silver</asp:ListItem>

                        <asp:ListItem Value="Yellow"> Yellow </asp:ListItem>








More Articles

© 2020 DotNetHeaven. All rights reserved.