Practical No:01
Practical No:01
Practical No:01
Working with basic C# and ASP .NET
a)Create an application that obtains four int values from the user and displays the
product.
Code:
Product.aspx
<%@PageLanguage="C#"AutoEventWireup="true"
CodeBehind="Product.aspx.cs"Inherits="Practical1_a_.Product" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
<asp:Image ID="Image1" runat="server" Height="199px" ImageUrl="~/WhatsApp
Image 2024-07-26 at 16.56.43_b52d341c.jpg" Width="228px" />
<br />
<asp:Label ID="lbl6" runat="server" Font-Bold="True" Font-Italic="True" Font-
Size="XX-Large" Font-Underline="True" Text="Mohammad Arbaz 48"></asp:Label>
<br />
<br />
<asp:Label ID="lbl1" runat="server" BorderStyle="Ridge" Text="Enter First
Number:"></asp:Label>
<asp:TextBox ID="txt1" runat="server" BorderStyle="Ridge"></asp:TextBox>
<br />
<br />
<asp:Label ID="lbl2" runat="server" BorderStyle="Ridge" Text="Enter Second
Number:"></asp:Label>
<asp:TextBox ID="txt2" runat="server" BorderStyle="Ridge"></asp:TextBox>
<br />
<br />
<asp:Label ID="lbl3" runat="server" BorderStyle="Ridge" Text="Enter Third
Number:"></asp:Label>
<asp:TextBox ID="txt3" runat="server" BorderStyle="Ridge"></asp:TextBox>
<br />
<br />
<asp:Label ID="lbl4" runat="server" BorderStyle="Ridge" Text="Enter Fourth
Number:"></asp:Label>
<asp:TextBox ID="txt4" runat="server" BorderStyle="Ridge"></asp:TextBox>
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
<br />
<br />
<asp:Button ID="btn1" runat="server" BorderStyle="Ridge" OnClick="btn1_Click"
Text="Calculate" />
<br />
<br />
<asp:LabelID="lbl5"runat="server"Text="Output"BorderStyle="Ridge"></asp:Label>
<br />
</center>
</form>
<p>
&n
bsp;
</p>
</body>
</html>
Design:
Product.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical1_a_
{
public partial class Product : System.Web.UI.Page
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
{
protected void Page_Load(object sender, EventArgs e)
{
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
Output:
Name.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Name.aspx.cs"
Inherits="Practical1_b_.Name" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
</center>
</form>
</body>
</html>
Design:
Name.aspx.cs
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical1_b_
{
public partial class Name : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
Output:
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
Fibonacci.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
</head>
<body>
<form id="form1" runat="server">
<center>
</center>
</form>
</body>
</html>
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
Design:
Fibonacci.aspx.cs
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical1_c_
{
public partial class Fibonacci : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
int sum = 0;
Response.Write("fibonacci Series: " + fno + "," + sno);
int i = 2;
while (i < usrInputNumber)
{
sum = fno + sno;
Response.Write("," + sum);
fno = sno;
sno = sum;
i++;
}
}
else if (DropDownList1.SelectedItem.Text.Equals("Prime"))
{
int num1 = Convert.ToInt32(txt1.Text.ToString());
int i;
for(i=2;i<num1-1;i++)
{
if (num1 % i == 0)
{
break;
}
if (i < num1 - 1)
{
lbl3.Text = "IS NOT A PRIME NUMBER";
}
else
{
lbl3.Text = "A PRIME NUMBER";
}
}
}
else if (DropDownList1.SelectedItem.Text.Equals("Vowels"))
{
string str=txt1.Text.ToString().ToLower();
int c = 0;
for(int i=0;i<str.Length;i++)
{
if ((str.Substring(i, 1)) == "a" || (str.Substring(i, 1)) == "e" || (str.Substring(i,
1)) == "i" || (str.Substring(i, 1)) == "o" || (str.Substring(i, 1)) == "u")
{
c++;
}
}
lbl3.Text = ("Total number of vowels in " + str + " is " + c);
}
else if(DropDownList1.SelectedItem.Text.Equals("Reverse and Find sum of
Digit"))
{
int num1=Convert.ToInt32(txt1.Text.ToString());
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
int reverse = 0;
int sum = 0;
while(num1 != 0)
{
int remainder = num1 % 10;
reverse=reverse*10 + remainder;
sum=remainder+sum;
num1=num1/10;
}
lbl3.Text = "<br>" + "Reverse of entered number is" + reverse + "<br>" + "Sum
of digits is" + sum;
}
else
{
String s = txt1.Text.ToString();
foreach(char c in s)
{
Response.Write("<br>" + c);
}
}
}
}
}
Output:
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
Practical No:02
Working with Object Oriented C# and ASP .NET
a)Create simple application to perform following operations
i. Finding factorial Value ii. Money Conversion
iii. Quadratic Equation iv. Temperature Conversion
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
</center>
</form>
</body>
</html>
Design:
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
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 Practical2_a_i
{
public partial class Factorial : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Output:
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
MoneyConversion.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
<br />
<br />
<asp:Label ID="lbl2" runat="server" BorderStyle="Ridge" Text="Select The
Conversion"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Rupees to Dollar</asp:ListItem>
<asp:ListItem>Dollar to Rupees</asp:ListItem>
<asp:ListItem>Rupees to Euro</asp:ListItem>
<asp:ListItem>Euro to Rupees</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Button ID="btn1" runat="server" BorderStyle="Ridge" OnClick="btn1_Click"
Text="Convert" />
<br />
<br />
<asp:Label ID="lbl3" runat="server" BorderStyle="Ridge"
Text="Output"></asp:Label>
</center>
</form>
</body>
</html>
Design:
MoneyConversion.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2_a_ii
{
public partial class MoneyConversion : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Output:
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
QuadraticEquation.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="QuadraticEquation.aspx
.cs" Inherits="Practical2_a_iii.QuadraticEquation" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
</center>
</form>
</body>
</html>
Design:
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
QuadraticEquation.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2_a_iii
{
public partial class QuadraticEquation : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public class quadeqtn
{
public double d, x1, x2;
public string msg;
public quadeqtn(int a,int b,int c)
{
d = b * b - 4 * a * c;
if (d == 0)
{
x1 = -b / (2.0 * a);
x2 = x1;
msg = "Boths the roots are equal<br>1st Root is: " + x1 + "<br>2nd Root is: "
+ x2 + "<br>";
}
else if (d > 0)
{
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
Output:
TemperatureConversion.aspx
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
</center>
</form>
</body>
</html>
Design:
TemperatureConversion.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2_a_iv
{
public partial class TemperatureConversion : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public class convert
{
public double temp, f, c;
public convert(double t)
{
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
temp = t;
}
public void ctf()
{
f = ((temp * 9 / 5)) + 32;
}
public void ftc()
{
c = ((temp - 32) * 5) / 9;
}
}
Output:
Mohammad Arbaz 48
T.Y.BSc(I.T) SEM-V Advanced Web Programming
Mohammad Arbaz 48