Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

P18:Desgin an ASP.

NET application for web controls and their implementation


Name:SwagatiPachare
Date:10/4/24
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" 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 id="Head1" runat="server">
<title>Web Controls </title>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 253px; width: 939px">
<asp:Label ID="lblMessage" runat="server" Text="Select an item and enter some text:"></asp:Label>
<br />
<asp:DropDownList ID="ddlItems" runat="server">
<asp:ListItem>Name</asp:ListItem>
<asp:ListItem>Age</asp:ListItem>
<asp:ListItem>Location</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:TextBox ID="txtInput" runat="server" Width="200px"></asp:TextBox>
<br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
<br />
<br />
<asp:Label ID="lblOutput" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>

Default.aspx.cs
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Initialize the dropdown list and text box if it's the first load
ddlItems.SelectedIndex = 0;
txtInput.Text = string.Empty;
}
}

protected void btnSubmit_Click(object sender, EventArgs e)


{
// Display the selected item and the entered text
lblOutput.Text = "Hello";

}
}

Output:

You might also like