0% found this document useful (0 votes)
6 views3 pages

ASP.NET Web Form Registration Example

The document outlines a simple ASP.NET web form for user registration, including fields for name, gender selection, and agreement to terms. It features server-side controls such as labels, text boxes, a dropdown list, a checkbox, and a submit button. Upon submission, the form validates the inputs and displays a message based on the user's selections and agreement status.

Uploaded by

ca235113119
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)
6 views3 pages

ASP.NET Web Form Registration Example

The document outlines a simple ASP.NET web form for user registration, including fields for name, gender selection, and agreement to terms. It features server-side controls such as labels, text boxes, a dropdown list, a checkbox, and a submit button. Upon submission, the form validates the inputs and displays a message based on the user's selections and agreement status.

Uploaded by

ca235113119
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

WEB CONTROLS

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"


Inherits="WebControlsApp.WebForm1" %>

<!DOCTYPE html>

<html xmlns="[Link]

<head runat="server">

<title>Web Controls Example</title>

</head>

<body>

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

<div style="padding: 20px; width: 300px; border: 1px solid #ccc;">

<h2>Registration Form</h2>

<asp:Label ID="Label1" runat="server" Text="Name:"


AssociatedControlID="txtName"></asp:Label><br />

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

<asp:Label ID="Label2" runat="server" Text="Gender:"></asp:Label><br />

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

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

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

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

</asp:DropDownList><br /><br />

<asp:CheckBox ID="chkAgree" runat="server" Text="I agree to the terms." /><br /><br />

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


/><br /><br />

<asp:Label ID="lblResult" runat="server" ForeColor="Green"></asp:Label>

</div>
</form>

</body>

</html>

using System;

namespace WebControlsApp

public partial class WebForm1 : [Link]

protected void Page_Load(object sender, EventArgs e)

protected void btnSubmit_Click(object sender, EventArgs e)

if ([Link])

string name = [Link];

string gender = [Link];

if (![Link](name) && ![Link](gender))

[Link] = $"Hello {name}! Gender selected: {gender}.";

else

[Link] = "Please fill all the fields.";

else

[Link] = "You must agree to the terms.";


}

You might also like