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

Sample Programs

The document contains multiple ASP.NET web forms that demonstrate basic functionalities such as displaying a name, adding two numbers, checking if a number is even or odd, showing a multiplication table, and selecting gender using radio buttons. Each functionality is implemented with a corresponding HTML layout and C# backend code. The forms utilize server controls and event handling to process user input and display results.

Uploaded by

kirti.pathak2005
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)
3 views6 pages

Sample Programs

The document contains multiple ASP.NET web forms that demonstrate basic functionalities such as displaying a name, adding two numbers, checking if a number is even or odd, showing a multiplication table, and selecting gender using radio buttons. Each functionality is implemented with a corresponding HTML layout and C# backend code. The forms utilize server controls and event handling to process user input and display results.

Uploaded by

kirti.pathak2005
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

1.

Display Name using TextBox


[Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="[Link]"
Inherits="NameDisplay" %>

<!DOCTYPE html>
<html>
<head>
<title>Name Display</title>
</head>

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

<h3>Enter Your Name</h3>

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

<br /><br />

<asp:Button ID="btnShow" runat="server" Text="Show Name"


OnClick="btnShow_Click" />

<br /><br />

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

</form>
</body>
</html>
[Link]
using System;

public partial class NameDisplay : [Link]


{
protected void btnShow_Click(object sender, EventArgs e)
{
[Link] = "Hello " + [Link];
}
}

2. Addition of Two Numbers


[Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="[Link]"
Inherits="Addition" %>
<!DOCTYPE html>
<html>
<head>
<title>Addition</title>
</head>

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

<h3>Add Two Numbers</h3>

Number 1:
<asp:TextBox ID="txt1" runat="server"></asp:TextBox>

<br /><br />

Number 2:
<asp:TextBox ID="txt2" runat="server"></asp:TextBox>

<br /><br />

<asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" />

<br /><br />

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

</form>
</body>
</html>
[Link]
using System;

public partial class Addition : [Link]


{
protected void btnAdd_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32([Link]);
int b = Convert.ToInt32([Link]);

int sum = a + b;

[Link] = "Sum = " + sum;


}
}

3. Even or Odd Number


[Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="[Link]"
Inherits="EvenOdd" %>

<!DOCTYPE html>
<html>
<head>
<title>Even Odd</title>
</head>

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

<h3>Check Even or Odd</h3>

Enter Number:
<asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>

<br /><br />

<asp:Button ID="btnCheck" runat="server" Text="Check"


OnClick="btnCheck_Click" />

<br /><br />

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

</form>
</body>
</html>
[Link]
using System;

public partial class EvenOdd : [Link]


{
protected void btnCheck_Click(object sender, EventArgs e)
{
int num = Convert.ToInt32([Link]);

if (num % 2 == 0)
{
[Link] = "Number is Even";
}
else
{
[Link] = "Number is Odd";
}
}
}

4. Multiplication Table
[Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="[Link]"
Inherits="Table" %>

<!DOCTYPE html>
<html>
<head>
<title>Multiplication Table</title>
</head>

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

<h3>Multiplication Table</h3>

Enter Number:
<asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>

<br /><br />

<asp:Button ID="btnShow" runat="server" Text="Show Table"


OnClick="btnShow_Click" />

<br /><br />

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

</form>
</body>
</html>
[Link]
using System;

public partial class Table : [Link]


{
protected void btnShow_Click(object sender, EventArgs e)
{
int n = Convert.ToInt32([Link]);

string result = "";

for (int i = 1; i <= 10; i++)


{
result += n + " x " + i + " = " + (n * i) + "<br/>";
}

[Link] = result;
}
}

5. Gender Selection using RadioButton


[Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="[Link]"
Inherits="Gender" %>

<!DOCTYPE html>
<html>
<head>
<title>Gender Selection</title>
</head>

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

<h3>Select Gender</h3>

<asp:RadioButton ID="rbMale" runat="server" Text="Male"


GroupName="gender" />

<br />

<asp:RadioButton ID="rbFemale" runat="server" Text="Female"


GroupName="gender" />

<br /><br />

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


OnClick="btnSubmit_Click" />

<br /><br />

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

</form>
</body>
</html>
[Link]
using System;

public partial class Gender : [Link]


{
protected void btnSubmit_Click(object sender, EventArgs e)
{
if ([Link])
{
[Link] = "Male Selected";
}
else if ([Link])
{
[Link] = "Female Selected";
}
}
}

You might also like