Awp 166
Awp 166
PRACTICAL: 1A
AIM:- Create an application that obtains four int values from the user and
displays the product
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Product
{
class Program
{
static void Main(string[] args)
{
int n1, n2, n3, n4, prod;
Console.WriteLine("Enter number 1: ");
n1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter number 2: ");
n2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter number 3: ");
n3 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter number 4: ");
n4 = Convert.ToInt32(Console.ReadLine());
prod = n1 * n2 * n3 * n4;
Console.WriteLine("Product of n1= {0} n2= {1} n3= {2} n4= {3} = {4}", n1, n2, n3,
n4, prod);
Console.ReadLine();
}
}
}
OUTPUT:-
PRACTICAL: 1B
AIM:- Create an application to demonstrate string operations.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_1
{
internal class Program
{
static void Main(string[] args)
{
String s1 = "HELLO MANISH";
Console.Write("s1:" + s1);
Console.WriteLine();
Console.WriteLine("enter string");
string s2 = Console.ReadLine();
Console.WriteLine();
string s3 = string.Copy(s1);
Console.WriteLine("copy string s3");
string s4 = string.Concat(s1, s3);
Console.WriteLine("concationation:" + s4);
int no = 786;
string s5 = no.ToString();
Console.WriteLine("converting no string:" + s5);
string s6 = "lean";
Console.WriteLine("O.G string:" + s6);
string s7 = s6.Insert(3, "r");
Console.WriteLine("Insertion:" + s7);
Console.WriteLine();
int n = string.Compare(s1, s2);
Console.WriteLine("comparison:" + n);
bool b1 = s1.Equals(s1);
Console.WriteLine("Equal b1:" + b1);
Console.WriteLine();
bool b2 = string.Equals(s1, s2);
Console.WriteLine("Equal b2:" + b2);
Console.WriteLine();
bool b3 = (s1 == s2);
Console.WriteLine("==b3" + b3);
Console.WriteLine();
string x = "xyz";
Console.WriteLine("O.G string:" + x);
int i = x.IndexOf('x');
Console.WriteLine("Index of a:" + i);
Console.WriteLine();
string y = "SIR";
Console.WriteLine("O.G string a:" + y);
int j = y.LastIndexOf('a');
Console.WriteLine();
string z = "bye see you";
Console.WriteLine("O.G string a:" + z);
string p = z.Replace('e', 'y');
Console.WriteLine("Replace string:" + p);
Console.WriteLine();
p = "hello welcome to my world";
Console.WriteLine("orignal string:" + p);
z = p.Remove(2);
x = p.Remove(2, 4);
Console.WriteLine("remoe string with parameter:" + z);
Console.WriteLine("remoe string with parameter:" + x);
Console.WriteLine();
x = "HINDUSTAN INDIA";
Console.WriteLine("orignal string:" + x);
z = x.Substring(5);
Console.WriteLine("substring with single parameter:" + z);
p = x.Substring(1,5);
Console.WriteLine("substring with two parameter:" + p);
Console.WriteLine();
x = "aligned";
Console.WriteLine("orignal string:" + x);
z = x.PadLeft(10, '*');
Console.WriteLine("orignal string:" + z);
p = x.PadRight(10, '*');
Console.WriteLine("orignal string:" + p);
Console.WriteLine();
x = "changed";
char[] dest = { 't', 'h', 'e', ' ', ' ', 'i', 'n', 'i', 't', 'i', 'a', 'l', ' ', 'a', 'r', 'r', 'a', 'y' };
Console.WriteLine("dest");
x.CopyTo(0, dest, 4, x.Length);
Console.WriteLine(dest);
Console.ReadLine();
}
}
}
OUTPUT:-
PRACTICAL-1C
AIM:- Create an application that receives the (Student, Student Name, Course
Name, Date of Birth) Information from a set of students, the application should
also display the information of all the student once the data is entered.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace parctical_1d.i
{
class Program
{
struct stud
{
public int id;
public string name, cource, dob;
}
static void Main(string[] args)
{
Console.WriteLine("enter student detail");
stud[] s = new stud[3];
for (int i = 0; i < 3; i++)
Console.WriteLine("*------*");
Console.WriteLine("student information");
for (int i = 0; i < 3; i++)
{
Console.WriteLine("ID=" + s[i].id);
Console.WriteLine("NAME=" + s[i].name);
Console.WriteLine("COURCE=" + s[i].cource);
Console.WriteLine("DOB=" + s[i].dob);
Console.ReadKey();
}
}
}
}
OUTPUT:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_1d.ii
{
internal class Program
{
static void Main(string[] args)
{
int i, f1, f2, fib;
Console.WriteLine("enter no of itration that your want");
i = int.Parse(Console.ReadLine());
f1 = 0;
f2 = 1;
Console.WriteLine(f1);
Console.WriteLine(f2);
for (int j = 2; j < i; j++)
{
fib = f1 + f2;
f1 = f2;
f2 = fib;
Console.WriteLine(fib);
}
Console.ReadKey();
}
}
}
Output:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrimeNumber
{
class Program
{
static void Main(string[] args)
{
int i, no, j;
bool flag = true;
Console.WriteLine("Enter Any no ");
no = int.Parse(Console.ReadLine());
for (i = 2; i < no; i++)
{
for (j = 2; j <= no; j++)
{
if (i != j && i % j == 0)
{
flag = false;
break;
}
}
if (flag == true)
{
Output: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_1d.iii
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter a string");
string str = Console.ReadLine();
char[] letter = str.ToCharArray();
foreach (char c in letter)
{
string s = vowel(c);
Console.WriteLine("{0} is {1}", c, s);
}
Console.ReadKey();
}
public static string vowel(char a)
{
switch (a)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
return ("avowel");
break;
default:
return (" not a vowel");
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_1d.iv
{
internal class Program
{
static void Main(string[] args)
{
string[] name = { "manish", "pooja", "mantu", "jay" };
foreach (string m in name)
{
Console.WriteLine(m);
}
Console.ReadKey();
}
}
}
Output: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_1d.v
{
internal class Program
{
static void Main(string[] args)
{
int r, no, i, rev = 0, sum = 0;
Console.WriteLine("enter any no:");
no = int.Parse(Console.ReadLine());
while(no!=0)
{
r = no % 10;
rev = (rev * 10) + r;
sum = sum + r;
no = no / 10;
}
Console.WriteLine("reverse=" + rev);
Console.WriteLine("sum=" + sum);
Console.ReadKey();
}
}
}
Output: -
PRACTICAL: 2A
AIM:- Create Simple application to perform following operation.
A(i)- Finding Factorial Value.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_1e.i
{
internal class Program
{
static void Main(string[] args)
{
int no, fact = 1;
Console.WriteLine("enter a no");
no = int.Parse(Console.ReadLine());
for (int i = 1; i<=no; i++)
{
fact = fact * i;
}
Console.WriteLine("factorial=" + fact);
Console.ReadKey();
}
}
}
Output: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MoneyConversion
{
class Program
{
static void Main(string[] args)
{
String ans = " ";
do
{
Console.WriteLine("Enter currency in Rs");
int r = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Select ur choice to convert into \n1.Dollar
\n2.Pounds \n3.Euro");
int n = Convert.ToInt32(Console.ReadLine());
double d = 0;
Console.WriteLine("Currency Converter");
switch (n)
{
case 1:
d = r / 68.5;
Console.WriteLine(r + "Rs=" + d + "$");
break;
case 2:
d = r / 89.48;
Console.WriteLine(r + "Rs=" + d + "Pounds");
break;
case 3:
d = r / 79.64;
Console.WriteLine(r + "Rs=" + d + "Euro");
break;
default:
Console.WriteLine("Invalid Choice");
break;
}
Console.WriteLine("Do u want to continue??");
ans = Console.ReadLine();
}
while (ans != "n");
Console.ReadKey();
}
}
}
Output: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_2A_iii
{
internal class Program
{
public static void solveQuadratic( int a,int b, int c)
{
double sqrtpart = b * b - 4 * a * c;
double x, x1, x2, img;
if(sqrtpart>0)
{
x1 = (-b + System.Math.Sqrt(sqrtpart)) / (2 * a);
x2 = (-b - System.Math.Sqrt(sqrtpart))/(2 * a);
Console.WriteLine("two real solution:{0,8:f4} or {1,8:f4}", x1, x2);
}
else if (sqrtpart<0)
{
sqrtpart = -sqrtpart;
x = -b / (2 * a);
img = System.Math.Sqrt(sqrtpart) / (2 * a);
Console.WriteLine("two imaginary solution:{0,8:f4}+{1,8,f4}i or {2,8:f4} +
{3,8:f4}i", img, x, img);
}
else
{
x = (-b + System.Math.Sqrt(sqrtpart)) / (2 * a);
Console.WriteLine("one real solution:{0,8:f4}", x);
}
}
static void Main(string[] args)
{
solveQuadratic(6, 11, -35);
solveQuadratic(5, 6, 1);
solveQuadratic(2, 4, 2);
solveQuadratic(5, 2, 1);
Console.ReadKey();
}
}
}
Output: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_2A_iv
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter temprature in fehrenhit");
double f, c;
f = Convert.ToDouble(Console.ReadLine());
c = (f - 32) * 5/9;
Console.WriteLine("after conversio ter parature in celsius:={0}", c);
Console.ReadLine();
}}}
Output:-
PRACTICAL- 2B
AIM:- Create simple application to demonstrate the use of following concepts.
2.B(i)- Function Overloading.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_2A_ii
{
internal class Program
{
public float Area (float x)
{
return (x * x);
}
public int Area (int l, int h)
{
return (l * h);
}
public double Area (double r)
{
return (Math.PI*r*r);
}
public float Area (float l, float h)
{
return (0.5F * l * h);
}
static void Main(string[] args)
{
Program P = new Program();
Console.WriteLine("Area of square =" + P.Area(10));
Console.WriteLine("Area of rectangle="+P.Area(4,5));
Console.WriteLine("Area of circle =" + P.Area(3.0));
Console.WriteLine("Area of Triangle=" + P.Area(1.2F, 3F));
Console.ReadKey();
}
}
}
output: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Inheritance
{
class A
{
public int a;
public A(int x)
{
a = x;
}
public void showA()
{
Console.WriteLine("A Show A=" + a);
}
}
class B : A
{
int v;
public B(int z, int y) : base(z)
{
v = y;
}
public void showB()
{
Console.WriteLine("B show B=" + v);
}
}
class C : A
{
int n;
public C(int x, int m) : base(x)
{
n = m;
}
public void showC()
{
Console.WriteLine("C Show C=" + n);
}
}
class D : B
{
int d;
public D(int x, int y, int z) : base(x, y)
{
d = z;
}
public void showD()
{
Console.WriteLine("D Show D=" + d);
}
}
class Program
{
static void Main(string[] args)
{
C c1 = new C(5, 9);
D d1 = new D(4, 2, 3);
c1.showA();
c1.showC();
d1.showA();
d1.showB();
d1.showD();
Console.ReadKey();
}}}
Output:-
2.B(iii)-Constructor Overloading.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_2B3
{ internal class Program
{
int x, y;
public Program()
{
Console.WriteLine("Default Constuctor");
x = y = 0;
}
public Program(int a)
{
Console.WriteLine("Parameterize constructor");
x = y = a;
}
public Program(int a, int b)
{
Console.WriteLine("Parameterize constructor");
x = a; y = b;
}
public Program(Program o)
{
Console.WriteLine("Copy Constructor");
x = o.x; y = o.y;
}
static Program()
{
Console.WriteLine("satic Construtor");
}
public void show()
{
Console.WriteLine("x=" + x);
Console.WriteLine("y=" + y);
}
static void Main(string[] args)
{
Program P1 = new Program();
P1.show();
Program P2 = new Program(10);
P2.show();
Program P3 = new Program(20, 30);
P3.show();
Program P4 = new Program(P2);
P4.show();
Console.ReadKey();
}
}
}
Output: -
2.B(iv)- Interfaces.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical_2B
{
interface Addition
{ int Add(); }
interface subtraction
{ int sub(); }
class A : Addition, subtraction
{
int a, b;
public A(int x, int y)
{
a = x; b = y;
Console.WriteLine("1st No=" + a);
Console.WriteLine("2nd No=" + b);
}
public int Add()
{ return a = b; }
public int sub()
{ return a - b; }
}
internal class Program
{
static void Main(string[] args)
{
A o = new practical_2B.A(10, 20);
Addition obj1 = (Addition)o;
subtraction obj2 = (subtraction)o;
Console.WriteLine("Addition=" + obj1.Add());
Console.WriteLine("subtraction=" + obj2.sub());
Console.ReadKey();
}
}
}
Output: -
PRACTICAL: 2C
AIM:- Create simple application to demonstrate the use of following concepts.
2.C(i)- Using Delegates and event.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practiccal__2C
{
public delegate void EventHandler(string a);
class operation
{
public event EventHandler xyz;
public void Action(string a)
{
if (xyz != null)
{ xyz(a);
Console.WriteLine(a);
}
else
{Console.WriteLine("Not Registered");
}
} }
internal class Program
{
static void Main(string[] args)
{ operation o = new operation();
o.Action("Event Colling");
o.xyz += new EventHandler(CatchEvent);
Console.ReadKey();
}
public static void CatchEvent(string s)
{ Console.WriteLine("Method Calling");
Console.ReadLine();
}
}}
Output: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace practical__2C2
{
internal class Program
{
static void Main(string[] args)
{
int a = 10, b = 5, c = 5, x;
try { x = a / (b - c); }
catch (Exception e)
{
Console.WriteLine("Divide by zero error");
}
x = a / (b + c);
Console.WriteLine("x=" + x);
int[] d = { 10, 5 };
try { x = d[2] / a; }
catch (IndexOutOfRangeException e)
{
Console.WriteLine("Array Index Error");
}
try { div(); }
catch (DivideByZeroException)
{
Console.WriteLine("Caught intside main");
}
finally { Console.WriteLine("Inside main"); }
Console.ReadKey();
}
static int m = 10, n = 0;
public static void div()
{
int k;
try { k = m / n; }
catch (ArgumentException e)
{
Console.WriteLine("Caught Inside Div");
}
finally
{
Console.WriteLine("Inside Div");
Console.ReadKey();
}
}
}
}
Output: -
PRACTICAL: 3A
Aim: Create a simple web page with various sever controls to demonstrate
setting and use of their properties use of Validation controls.
Home.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 { text-
#000099;
.auto-style2 { background-color:
#FFFFFF;
.auto-style3 { text-
align: center;
.auto-style4 {
width: 100%;
</style>
</head>
<body>
<table class="auto-style4">
<tr>
<td>
<div class="auto-style1">
</td>
</tr>
<tr>
<td>
<div class="auto-style3">
</td>
</tr>
<tr>
<td class="auto-style3">
</td>
</tr>
</table>
</form>
</body>
</html>
login.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
.auto-style2 { text-
#000099;
</style>
</head>
<body>
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2"><strong>LOGIN</strong></td>
</tr>
<tr>
<td>Username:
</td>
</tr>
<tr>
<td>Password:
</td>
</tr>
<tr>
<td>Confirm Password:
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
login.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
else
txt_name.Text = "";
txt_pwd.Text = "";
txt_confpwd.Text = "";
Registration form.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
.auto-style2 { text-
#000099;
.auto-style3 { text-
align: center;
</style>
</head>
<body>
<table class="auto-style1">
<tr>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
</td>
</tr>
<tr>
</td>
</tr>
<tr>
<td> Course:
<asp:ListItem>IT</asp:ListItem>
<asp:ListItem>CS</asp:ListItem>
<asp:ListItem>DS</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style3">
</td>
</tr>
</table>
</form>
</body>
</html>
Registration form.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
(RadioButton1.Checked == true) g =
if (DropDownList1.SelectedValue == "IT") c =
if(DropDownList1.SelectedValue=="DS") c =
"22,200";
Receipt.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
.auto-style2 {
height: 23px;
color: #000099;
text-align:
center;
</style>
</head>
<body>
<td>
<table class="auto-style1">
<tr>
<td class="auto-style2"><strong>Receipt</strong></td>
</tr>
<tr>
<td>Name:
</td>
</tr>
<tr>
<td>Gender:
</td>
</tr>
<tr>
<td>Email:
</td>
</tr>
<tr>
<td>Course:
</td>
</tr>
<tr>
<td>Fees:
</td>
</tr>
</table>
</form>
</body>
</html>
using System.Collections.Generic;
using System.Web.UI.WebControls;
namespace Pract_3a
= Request.QueryString["Gender"]; lblEmail.Text =
Request.QueryString["Email"]; lblCourse.Text =
Request.QueryString["Course"]; lblFees.Text =
Request.QueryString["Fees"];
Fees Details.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
.auto-style2 { color:
#000099; text-
align: center;
.auto-style3 {
width: 632px;
.auto-style4 { text-
align: center;
</style>
</head>
<body>
<div class="auto-style4">
<div class="auto-style2">
<strong>Fees Details</strong></div>
<table class="auto-style1">
<tr>
<td class="auto-style3">
<asp:ListItem>IT</asp:ListItem>
</asp:BulletedList>
</td>
<td>25,500</td>
</tr>
<tr>
<td class="auto-style3">
<asp:ListItem>CS</asp:ListItem>
</asp:BulletedList>
</td>
<td>29,000</td>
</tr>
<tr>
<td class="auto-style3">
<asp:ListItem>DS</asp:ListItem>
</asp:BulletedList>
</td>
<td>22,200</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Fees Details.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Response.Redirect("Home.aspx");
}OUTPUT:
PRACTICAL: 3.B.
Practical:- 4
Aim: Demonstrate the use of Calendar control to perform following operations.
Calender.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
<p>
</p>
<p>
Today's date:
</p>
<p>
Ganpati Vactaion:
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</form>
</body>
</html>
Calender.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Calendar1.Caption = "SAMBARE";
Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday;
Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth;
Calendar1.TitleFormat = TitleFormat.Month;
if(Calendar1.SelectedDate.ToShortDateString() == "8-31-2022")
if(Calendar1.SelectedDate.ToShortDateString() == "9-4-2022")
Calendar1.SelectedDates.Clear();
if(e.Day.Date.Day==5&&e.Day.Date.Month==9)
e.Cell.BackColor = System.Drawing.Color.Yellow;
e.Cell.Controls.Add(lbl);
g1.ImageUrl = "/img/td.jpg";
g1.Height = 20;
g1.Width = 20;
e.Cell.Controls.Add(g1); }
if(e.Day.Date.Day==13&&e.Day.Date.Month==9)
e.Cell.Controls.Add(lbl1);
OUTPUT:
PRACTICAL: 5
Aim: Demonstrate the use of Treeview control perform following operations.
Default.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<Nodes>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
<br />
<FooterTemplate>
Record
</FooterTemplate>
<HeaderTemplate>
Student Details
</HeaderTemplate>
<ItemTemplate>
<br />
<br />
</ItemTemplate>
<SeparatorTemplate>
*********************
</SeparatorTemplate>
</asp:DataList>
<br />
</div>
</form>
</body>
</html>
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DataList
if (!IsPostBack)
BindData();
d.ReadXml(Server.MapPath("~/studentdetails.xml"));
DataList1.DataSource = d;
DataList1.DataBind();
studentdetails.xml
<studentDetails>
<student>
<sid>1</sid>
<sname>Manvesh</sname>
<course>TYIT</course>
</student>
<student>
<sid>2</sid>
<sname>Aysuh</sname>
<course>TYCS</course>
</student>
<student>
<sid>3</sid>
<sname>Hemant</sname>
<course>TYDS</course>
</student>
</studentDetails>
OUTPUT:
PRACTICAL: 6
Aim: Create Web Form to demonstrate use of Ad rotator Control.
AdRotator.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</div>
</form>
</body>
</html>
adds.xml
<Advertisements>
<Ad>
<ImageUrl>Chrysanthemum.jpg</ImageUrl>
<NavigateUrl>https://www.google.com</NavigateUrl>
<AlternateText>Google Search</AlternateText>
<Impressions>20</Impressions>
<Keyword>Google</Keyword>
</Ad>
<Ad>
<ImageUrl>Desert.jpg</ImageUrl>
<NavigateUrl>https://facebook.com</NavigateUrl>
<AlternateText>Facebook</AlternateText>
<Impressions>20</Impressions>
<Keyword>Facebook</Keyword>
</Ad>
<Ad>
<ImageUrl>Jellyfish.jpg</ImageUrl>
<NavigateUrl>https://www.w3schools.com</NavigateUrl>
<AlternateText>W3School</AlternateText>
<Impressions>20</Impressions>
<Keyword>W3School</Keyword>
</Ad>
<Ad>
<ImageUrl>Koala.jpg</ImageUrl>
<NavigateUrl>https://www.javatpoint.com</NavigateUrl>
<AlternateText>javatpoint</AlternateText>
<Impressions>20</Impressions>
<Keyword>javatpoint</Keyword>
</Ad>
</Advertisements>
OUTPUT:
Practical :- 7
Aim:-Create Web Form to demonstrate use User Controls.
Default.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
</form>
</body>
</html>
MyUserControl.ascx
<div>
Enter Name:
<br />
Enter City:
<br />
<br />
<br />
</div>
</form>
MyUserControl.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Label1.Text = "Your Name is " + txtName.Text + " and You are from " + txtCity.Text;
OUTPUT:
PRACTICAL: 8
a) Create a web application bind data in a multiline textbox by
querying in another textbox
Prac6a.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Prac6a.aspx.cs"
Inherits="Prac6a" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Prac6a.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
con.Open();
ListBox1.Items.Clear();
while(reader.Read())
for(int i=0;i<reader.FieldCount-1;i++)
ListBox1.Items.Add(reader[i].ToString());
reader.Close();
con.Close();
OUTPUT:
Practical:- 9
Aim:- Create a web application to display records by using database.
Prac6b.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Prac6b.aspx.cs"
Inherits="Prac6b" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Prac6b.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace p6
{
public partial class _6b : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
Practical:- 10
namespace p6
{
public partial class _6a : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
PRACTICAL: 11
Aim:- Create a web application for to display the phone no of an author
using database
Prac7b.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Prac7b.aspx.cs"
Inherits="Prac7b" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Prac7b.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
if(IsPostBack==false)
con.Open();
ListBox1.DataSource = reader;
ListBox1.DataTextField = "city";
ListBox1.DataValueField = "pincode";
ListBox1.DataBind();
Label1.Text = ListBox1.SelectedValue;
OUTPUT:
Practical:-12
Aim:- Create a web application for inserting and deleting record from a
database. (Using Execute-Non Query).
ExecuteNonQuery.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
ExecuteNonQuery.aspx.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac7c
cmd.Parameters.AddWithValue("@PERSON_ID", TextBox1.Text);
cmd.Parameters.AddWithValue("@FNAME", TextBox2.Text);
cmd.Parameters.AddWithValue("@LNAME", TextBox3.Text);
cmd.Parameters.AddWithValue("@", TextBox4.Text);
cmd.Parameters.AddWithValue("@STATE", TextBox4.Text);
cmd.Parameters.AddWithValue("@ZIP_CODE", TextBox5.Text);
con.Open();
cmd.Parameters.AddWithValue("@NAME",TextBox3.Text);
cmd.ExecuteNonQuery();
con.Open();
con.Close();
} } }
OUTPUT:
PRACTICAL: 13
Aim:- Create a web application to demonstrate reading and writing
operation with XML.
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<table>
<tr><td>Name:
<tr><td>Department:
<tr><td>Location:
<tr><td align="right">
</td></tr></table></td>
onclick="btnReadXml_Click"/><br/>
</table></div></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;
using System.Xml;
using System.Text;
ReadXmlFile(Server.MapPath("EmployeeDetails.xml"));
lblXml.Text = "";
while (xmlReader.Read())
if (xmlReader.NodeType == XmlNodeType.Element)
if (element)
element = true;
childElementName = xmlReader.Name;
element = false;
childElementValue = xmlReader.Value;
parentElementName = "";
childElementName = ""; }
} xmlReader.Close();
xmlEmloyeeDoc.Load(Server.MapPath("~/EmployeeDetails.xml"));
Name.InnerText = txtName.Text;
Department.InnerText = txtDept.Text;
Location.InnerText = txtLocation.Text;
ParentElement.AppendChild(Name);
ParentElement.AppendChild(Department);
ParentElement.AppendChild(Location);
xmlEmloyeeDoc.DocumentElement.AppendChild(ParentElement);
xmlEmloyeeDoc.Save(Server.MapPath("~/EmployeeDetails.xml"));
EmployeeDetails.xml
<?xml version="1.0" encoding="utf-8"?>
<EmployeeDetails>
<Details>
<Name>Manvesh</Name>
<Department>TYIT</Department>
<Location>Virar</Location>
</Details>
</EmployeeDetails>
OUTPUT:
PRACTICAL:- 13
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="AJAX.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
</asp:ScriptManager>
<ContentTemplate>
<br />
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</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 AJAX
Label1.Text = System.DateTime.Now.ToString();
Output:-