Drop Down List Control in asp.net
For Example: Write a program to demonstrate the use of Dropdown List control.
.ASPX file:
<html>
<head runat="server">
<title>Aryan Computers(Dropdown List Box) </title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Underline="True"
ForeColor="#CC0099" Text="Example of DropDown List Control"></asp:Label>
<br />
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>C Programming</asp:ListItem>
<asp:ListItem>C++ Programming</asp:ListItem>
<asp:ListItem>Core Java</asp:ListItem>
<asp:ListItem>ASP.Net</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Check item " />
</div>
<p>
<asp:Label ID="Label2" runat="server" Font-Bold="True"></asp:Label>
</p>
</form>
</body>
</html>
.ASPX.CS File
namespace WebApplication3
{
public partial class WebForm6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
{
if (DropDownList1.SelectedValue == "")
{
Label2.Text = "Please Select your Subject !!!";
}
else
Label2.Text = "You Select : " + DropDownList1.SelectedValue;
}
}
}
}
Output:
Comments
Post a Comment