PROGRAM TO CREATE A DROP DOWN LIST BOX

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Enter the item to add" Width="136px"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        <br />
        <asp:Button ID="Button1" runat="server" Font-Bold="True" Text="ADD" Width="113px" /><br />
        <br />
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem>RED</asp:ListItem>
            <asp:ListItem>BLUE</asp:ListItem>
            <asp:ListItem>GREEN</asp:ListItem>
            <asp:ListItem>YELLOW</asp:ListItem>
            <asp:ListItem>ORANGE</asp:ListItem>
            <asp:ListItem>PURPLE</asp:ListItem>
        </asp:DropDownList></div>
    </form>
</body>

</html>

DEFAULT.ASPX.VB FILE:

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        DropDownList1.Items.Add(TextBox1.Text)
    End Sub

End Class


No comments:

Post a Comment