Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views6 pages

Programs

This document provides a step-by-step guide to create an ASP.NET Web Application using standard controls in C#. It includes instructions for designing a Web Form with various controls such as Label, TextBox, DropDownList, CheckBox, ListBox, and a Button, along with the corresponding code-behind logic to handle form submissions. The output behavior is described, showing how user inputs are processed and displayed after form submission.

Uploaded by

gokul20051110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Programs

This document provides a step-by-step guide to create an ASP.NET Web Application using standard controls in C#. It includes instructions for designing a Web Form with various controls such as Label, TextBox, DropDownList, CheckBox, ListBox, and a Button, along with the corresponding code-behind logic to handle form submissions. The output behavior is described, showing how user inputs are processed and displayed after form submission.

Uploaded by

gokul20051110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1. To develop ASP.

NET web application using standard controls


using c# give complete coding

A Web Form with:

 Label
 TextBox
 Button
 DropDownList
 CheckBox
 ListBox
 A display Label

Step-by-Step ASP.NET Web Forms App


1. Create a New Web Application in Visual Studio

 File → New → Project → ASP.NET Web Application (.NET Framework)


 Choose Web Forms template
 Name it: MyWebApp

2. Default.aspx (Web Form Design)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>ASP.NET Standard Controls Demo</title>

<style>

body { font-family: Arial; padding: 20px; }

.form-section { margin-bottom: 20px; }

</style>
</head>

<body>

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

<div>

<h2>Welcome to ASP.NET Web App</h2>

<div class="form-section">

<asp:Label ID="Label1" runat="server" Text="Enter your name: "></asp:Label><br />

<asp:TextBox ID="txtName" runat="server"></asp:TextBox>

</div>

<div class="form-section">

<asp:Label ID="Label2" runat="server" Text="Choose a programming language:


"></asp:Label><br />

<asp:DropDownList ID="ddlLanguages" runat="server">

<asp:ListItem Text="--Select--" Value=""></asp:ListItem>

<asp:ListItem Text="C#" Value="C#"></asp:ListItem>

<asp:ListItem Text="Java" Value="Java"></asp:ListItem>

<asp:ListItem Text="Python" Value="Python"></asp:ListItem>

</asp:DropDownList>

</div>

<div class="form-section">

<asp:Label ID="Label3" runat="server" Text="Select your hobbies: "></asp:Label><br />

<asp:CheckBox ID="chkReading" runat="server" Text="Reading" /><br />


<asp:CheckBox ID="chkGaming" runat="server" Text="Gaming" /><br />

<asp:CheckBox ID="chkTraveling" runat="server" Text="Traveling" /><br />

</div>

<div class="form-section">

<asp:Label ID="Label4" runat="server" Text="Select favorite subjects: "></asp:Label><br />

<asp:ListBox ID="lstSubjects" runat="server" SelectionMode="Multiple" Rows="4">

<asp:ListItem Text="Maths" Value="Maths" />

<asp:ListItem Text="Physics" Value="Physics" />

<asp:ListItem Text="Computer Science" Value="CS" />

<asp:ListItem Text="English" Value="English" />

</asp:ListBox>

</div>

<div class="form-section">

<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />

</div>

<div class="form-section">

<asp:Label ID="lblOutput" runat="server" ForeColor="Green" Font-Bold="true"></asp:Label>

</div>

</div>

</form>

</body>
</html>

3. Default.aspx.cs (Code Behind)

using System;

using System.Text;

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

protected void btnSubmit_Click(object sender, EventArgs e)

StringBuilder output = new StringBuilder();

string name = txtName.Text.Trim();

string language = ddlLanguages.SelectedValue;

output.Append("Hello, " + name + "!<br/>");

if (!string.IsNullOrEmpty(language))

output.Append("Your favorite language is: " + language + "<br/>");

output.Append("Your hobbies include: ");

bool hasHobby = false;

if (chkReading.Checked) { output.Append("Reading "); hasHobby = true; }


if (chkGaming.Checked) { output.Append("Gaming "); hasHobby = true; }

if (chkTraveling.Checked) { output.Append("Traveling "); hasHobby = true; }

if (!hasHobby) { output.Append("None"); }

output.Append("<br/>Your favorite subjects are: ");

if (lstSubjects.GetSelectedIndices().Length > 0)

foreach (var item in lstSubjects.Items)

if (((System.Web.UI.WebControls.ListItem)item).Selected)

output.Append(((System.Web.UI.WebControls.ListItem)item).Text + " ");

else

output.Append("None");

lblOutput.Text = output.ToString();

Output Behavior:

After filling the form and clicking Submit:

 It displays a greeting.
 Shows selected programming language.
 Lists hobbies and subjects selected.

To Run:

1. Open in Visual Studio.


2. Press F5 or click Start Debugging.
3. Fill form → Click Submit → See the results.

You might also like