listbox.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="listbox.aspx.cs" Inherits="our_program.listbox" %>
<!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">
<center><h1>LIST BOX AND SELECTED VALUE</h1></center>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:ListBox ID="blt" runat="server" Height="169px" Width="118px" ></asp:ListBox>
<br />
<asp:Button ID="btn" runat="server" Text="Button" onclick="btn_Click" />
<br />
<asp:Label ID="lbl" runat="server" Text="selected value is shown here"></asp:Label>
</div>
</center>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="listbox.aspx.cs" Inherits="our_program.listbox" %>
<!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">
<center><h1>LIST BOX AND SELECTED VALUE</h1></center>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:ListBox ID="blt" runat="server" Height="169px" Width="118px" ></asp:ListBox>
<br />
<asp:Button ID="btn" runat="server" Text="Button" onclick="btn_Click" />
<br />
<asp:Label ID="lbl" runat="server" Text="selected value is shown here"></asp:Label>
</div>
</center>
</form>
</body>
</html>
listbox.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace our_program
{
public partial class listbox : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
blt.Items.Add("JAN");
blt.Items.Add("FEB");
blt.Items.Add("MAR");
blt.Items.Add("APR");
blt.Items.Add("MAY");
blt.Items.Add("JUN");
blt.Items.Add("JUL");
blt.Items.Add("AUG");
blt.Items.Add("SEP");
blt.Items.Add("OCT");
blt.Items.Add("NOV");
blt.Items.Add("DEC");
}
protected void btn_Click(object sender, EventArgs e)
{
lbl.Text = "YOU ARE SELECTED MONTH IS :" + blt.SelectedItem.ToString();
}
}
}
No comments:
Post a Comment