Factorial.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Fact.aspx.cs"
Inherits="TemperatureConversion.Fact" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
Enter the Number : <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div> <p>
<asp:Button ID="Button1" runat="server" Text=" Find Factorial "
OnClick="Button1_Click" />
</p> <p>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</p>
</form>
</body>
</html>
Factorial.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace factorial
{
public partial class Fact : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int n, f = 1;
n = Convert.ToInt32(TextBox1.Text);
for(int i=1;i<n;i++)
{
f = f * i;
}
Label1.Text="The Factorial is : "+f.ToString();
}
}
}
0 Comments