Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs"
Inherits="Conversion._default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
Enter Number : <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Fibonacci Series" Width="150px"
OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label> </div>
<p>
Enter Number : <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Text="Check Prime No." Width="150px"
OnClick="Button2_Click" />
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
</p> <p>
Enter Number : <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:Button ID="Button3" runat="server" Text="Reverse No." Width="150px"
OnClick="Button3_Click" />
<asp:Label ID="Label3" runat="server" Text=""></asp:Label>
</p>
<p>
Enter Number : <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:Button ID="Button4" runat="server" Text="Sum of digit of No." Width="150px"
OnClick="Button4_Click" />
<asp:Label ID="Label4" runat="server" Text=""></asp:Label>
</p> <p>
Enter Character : <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:Button ID="Button5" runat="server" Text="Check Vowels or Not" Width="150px"
OnClick="Button5_Click" />
<asp:Label ID="Label5" runat="server" Text=""></asp:Label>
</p>
<p> </p>
<p>
Reading array by foreach loop : </p>
<p>
<asp:Label ID="Label6" runat="server" Text=""></asp:Label>
</p>
</form> </body>
</html>
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Conversion
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label6.Text = "";
string[] colorname = new string[] { "Red", "Yello", "Black", "Green", "Blue", "pink" };
foreach (string colname in colorname)
{
Label6.Text = Label6.Text + " " + colname.ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int a, b, c, i, n;
a = 0;
b = 1;
Label1.Text = a.ToString() + b.ToString();
n = Convert.ToInt32(TextBox1.Text);
for (i = 1; i < n; i++)
{
c = a + b;
Label1.Text = Label1.Text + " " + c.ToString();
a = b;
b = c;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
int number;
number = Convert.ToInt32(TextBox2.Text);
int i;
for (i = 2; i < number; i++)
{
if (number % i == 0)
{
Label2.Text = ("Number is not Prime Number");
break;
}
}
if (i == number)
{
Label2.Text = ("Number is Prime Number");
}
}
protected void Button3_Click(object sender, EventArgs e)
{
int num, i, sum = 0;
num = Convert.ToInt32(TextBox3.Text);
while (num > 0)
{
i = num % 10;
sum = i + sum * 10;
num /= 10;
}
Label3.Text = sum.ToString();
}
protected void Button4_Click(object sender, EventArgs e)
{
int num, i, sum = 0;
num = Convert.ToInt32(TextBox5.Text);
while (num > 0)
{ i = num % 10;
sum = i + sum;
num /= 10;
}
Label4.Text = sum.ToString();
}
protected void Button5_Click(object sender, EventArgs e)
{
char c = Convert.ToChar(TextBox4.Text);
switch (c)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
Label5.Text = "It is a vowel";
break;
default:
Label5.Text = "It is Consonant Character";
break;
}
}
}
}
0 Comments