0% found this document useful (0 votes)
29 views

Awp 166

The document contains code snippets from multiple C# programming exercises: 1. A program that gets 4 integer inputs from the user and displays their product. 2. A program demonstrating various string operations like concatenation, comparison, indexing, etc. 3. A program that gets student details like name, course, and DOB into a struct array and displays the information. 4. Programs to (i) generate Fibonacci series, (ii) check if a number is prime, (iii) check if a character is a vowel, (iv) calculate simple and compound interest, and (v) calculate area and circumference of a circle. Each code snippet is attributed to the student Pratik Singh with roll
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Awp 166

The document contains code snippets from multiple C# programming exercises: 1. A program that gets 4 integer inputs from the user and displays their product. 2. A program demonstrating various string operations like concatenation, comparison, indexing, etc. 3. A program that gets student details like name, course, and DOB into a struct array and displays the information. 4. Programs to (i) generate Fibonacci series, (ii) check if a number is prime, (iii) check if a character is a vowel, (iv) calculate simple and compound interest, and (v) calculate area and circumference of a circle. Each code snippet is attributed to the student Pratik Singh with roll
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86

T.Y.B.Sc.I.

T Advance Web Programming

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();
}
}
}

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

OUTPUT:-

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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();

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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();

}
}
}

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

OUTPUT:-

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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("enter student id");


s[i].id = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter student name");
s[i].name = Console.ReadLine();
Console.WriteLine("enter student cource");
s[i].cource = Console.ReadLine();
Console.WriteLine("enter student dob");
s[i].dob = Console.ReadLine();
}

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();

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

}
}
}
}

OUTPUT:-

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

PRACTICAL:1.D(i, ii, iii, iv, v)


AIM:- create an application to demostrate use of following concepts.
1.d(i)- Generate Fibonacci Series.

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();
}
}
}

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Output:-

1.d(ii)- Test for Prime Number.

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)
{

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Console.WriteLine("\n The Prime Number are:" + i);


}
flag = true;
}
Console.ReadKey();
}
}
}

Output: -

1.d(iii)- Test For Vowels.

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)
{

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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");

}
}

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

1.d(iv)- Use Of Foreach Loop With Arrays.

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: -

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

1. d(v)- Reverse a Number and Find Sum of Digitals of a Number.

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: -

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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: -

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

A(ii)- Money Conversion.

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");

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Console.ReadKey();
}
}
}

Output: -

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

A(iii)- Quadratic Equation.

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();

}
}
}

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Output: -

A(iv)- Temperature Conversion

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:-

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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();
}
}
}

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

output: -

2.B(ii)-Inheritance (all types).

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);

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

}
}
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:-

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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);

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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)

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

{
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: -

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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: -

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

2.C(ii)- Exception Handling.

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();

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

}
}
}
}

Output: -

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Home.aspx.cs"


Inherits="Pract_3a.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

<style type="text/css">

.auto-style1 { text-

align: center; color:

#000099;

.auto-style2 { background-color:

#FFFFFF;

.auto-style3 { text-

align: center;

.auto-style4 {

width: 100%;

</style>

</head>

<body>

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

<table class="auto-style4">

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<tr>

<td>

<div class="auto-style1">

<strong><span class="auto-style2">VIVA College</span></strong></div>

</td>

</tr>

<tr>

<td>

<div class="auto-style3">

<a id="LinkButton1" href="Login.aspx">Admission Process</a></div>

</td>

</tr>

<tr>

<td class="auto-style3">

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Fees Details.aspx">Fee


Structure</asp:HyperLink>

</td>

</tr>

</table>

</form>

</body>

</html>

login.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Pract_3a.Login" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<title></title>

<style type="text/css">

.auto-style1 {

width: 100%;

.auto-style2 { text-

align: center; color:

#000099;

</style>

</head>

<body>

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

<div>

<table class="auto-style1">

<tr>

<td class="auto-style2"><strong>LOGIN</strong></td>

</tr>

<tr>

<td>Username:&nbsp;

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

&nbsp;

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"


ControlToValidate="txt_name" ErrorMessage="FIELD SHOULD NOT BE
EMPTY"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td>Password:&nbsp;

<asp:TextBox ID="txt_pwd" runat="server" TextMode="Password"></asp:TextBox>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

</td>

</tr>

<tr>

<td>Confirm Password:&nbsp;

<asp:TextBox ID="txt_confpwd" runat="server" TextMode="Password"></asp:TextBox>

<asp:CompareValidator ID="CompareValidator1" runat="server"


ControlToValidate="txt_confpwd" ControlToCompare="txt_pwd" ErrorMessage="PASSWORD DOES NOT
MATCH"></asp:CompareValidator>

</td>

</tr>

<tr>

<td>

<asp:Button ID="btn_login" runat="server" Text="Login" OnClick="btn_login_Click" />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<asp:Button ID="btn_reset" runat="server" Text="Reset" OnClick="btn_reset_Click" />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

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

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

login.aspx.cs
using System;

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

if (txt_name.Text == "Disha" && txt_pwd.Text == "123") Response.Redirect("Registration


form.aspx");

else

Label1.Text = "Enter valid information";

protected void btn_reset_Click(object sender, EventArgs e)

txt_name.Text = "";

txt_pwd.Text = "";

txt_confpwd.Text = "";

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Registration form.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Registration form.aspx.cs"


Inherits="Pract_3a.Registration_form" %>

<!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-

align: center; color:

#000099;

.auto-style3 { text-

align: center;

</style>

</head>

<body>

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

<table class="auto-style1">

<tr>

<td class="auto-style2"><strong>Registration Form</strong></td>

</tr>

<tr>

<td>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<asp:Label ID="Label1" runat="server" Text="Name:"></asp:Label>

&nbsp;

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

</td>

</tr>

<tr>

<td>

<asp:Label ID="Label2" runat="server" Text="Age:"></asp:Label>

&nbsp;

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

&nbsp;

<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txt_age"


ErrorMessage="AGE BETWEEN 20 TO 60" MinimumValue="20"
MaximumValue="60"></asp:RangeValidator>

</td>

</tr>

<tr>

<td>&nbsp;<asp:Label ID="Label3" runat="server" Text="Gender:"></asp:Label>


&nbsp;<asp:RadioButton ID="RadioButton1" runat="server" Text="Male" />

&nbsp;

<asp:RadioButton ID="RadioButton2" runat="server" Text="Female" />

</td>

</tr>

<tr>

<td>&nbsp;<asp:Label ID="Label4" runat="server" Text="Email:"></asp:Label>

&nbsp;<asp:TextBox ID="txt_email" runat="server"></asp:TextBox>

&nbsp;

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"


ControlToValidate="txt_email" ErrorMessage="INVALID EMAIL ID"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>

</td>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

</tr>

<tr>

<td>&nbsp;Course:&nbsp;

<asp:DropDownList ID="DropDownList1" runat="server"


OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">

<asp:ListItem>IT</asp:ListItem>

<asp:ListItem>CS</asp:ListItem>

<asp:ListItem>DS</asp:ListItem>

</asp:DropDownList>

</td>

</tr>

<tr>

<td class="auto-style3">

<asp:Button ID="btn_register" runat="server" Text="Register" OnClick="btn_register_Click" />

</td>

</tr>

</table>

</form>

</body>

</html>

Registration form.aspx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void btnReceipt_Click(object sender, EventArgs e)

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

protected void btn_register_Click(object sender, EventArgs e)

string g, c = ""; string[] a = new string[4]; if

(RadioButton1.Checked == true) g =

RadioButton1.Text; else g = RadioButton2.Text;

if (DropDownList1.SelectedValue == "IT") c =

"25,500"; else if (DropDownList1.SelectedValue

== "CS") c = "29,000"; else

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

if(DropDownList1.SelectedValue=="DS") c =

"22,200";

Response.Redirect("Receipt.aspx?Name=" + text_name.Text + "&Gender=" + g + "&Email=" +


txt_email.Text + "&Course=" + DropDownList1.SelectedValue + "&Fees=" + c);

Receipt.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Receipt.aspx.cs"


Inherits="Pract_3a.Receipt1" %>

<!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>

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

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<td>

<table class="auto-style1">

<tr>

<td class="auto-style2"><strong>Receipt</strong></td>

</tr>

<tr>

<td>Name:&nbsp;&nbsp;

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

</td>

</tr>

<tr>

<td>Gender:&nbsp;&nbsp;

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

</td>

</tr>

<tr>

<td>Email:&nbsp;&nbsp;

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

</td>

</tr>

<tr>

<td>Course:&nbsp;&nbsp;

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

</td>

</tr>

<tr>

<td>Fees:&nbsp;&nbsp;

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

</td>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

</tr>

</table>

</form>

</body>

</html>

Receipt.aspx.cs: using System;

using System.Collections.Generic;

using System.Linq; using

System.Web; using System.Web.UI;

using System.Web.UI.WebControls;

namespace Pract_3a

public partial class Receipt1 : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

lblName.Text = Request.QueryString["Name"]; lblGender.Text

= Request.QueryString["Gender"]; lblEmail.Text =

Request.QueryString["Email"]; lblCourse.Text =

Request.QueryString["Course"]; lblFees.Text =

Request.QueryString["Fees"];

Fees Details.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Fees Details.aspx.cs"


Inherits="Pract_3a.Fees_Details" %>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<!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>

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

<div class="auto-style4">

<div class="auto-style2">

<strong>Fees Details</strong></div>

<table class="auto-style1">

<tr>

<td class="auto-style3">

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<asp:BulletedList ID="BulletedList1" runat="server">

<asp:ListItem>IT</asp:ListItem>

</asp:BulletedList>

</td>

<td>25,500</td>

</tr>

<tr>

<td class="auto-style3">

<asp:BulletedList ID="BulletedList2" runat="server">

<asp:ListItem>CS</asp:ListItem>

</asp:BulletedList>

</td>

<td>29,000</td>

</tr>

<tr>

<td class="auto-style3">

<asp:BulletedList ID="BulletedList3" runat="server" Height="16px" Width="594px">

<asp:ListItem>DS</asp:ListItem>

</asp:BulletedList>

</td>

<td>22,200</td>

</tr>

</table>

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Back" />

</div>

</form>

</body>

</html>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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;

public partial class Default3 : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

Response.Redirect("Home.aspx");

}OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

PRACTICAL: 3.B.

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Practical:- 4
Aim: Demonstrate the use of Calendar control to perform following operations.

a) Display messages in a calendar control


b) Display vacation in a calendar control
c) Selected day in a calendar control using style
d) Difference between two calendar dates

Calender.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calender.aspx.cs"


Inherits="Calender" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:Calendar ID="Calendar1" runat="server" Height="247px" Width="347px"


OnDayRender="Calendar1_DayRender"
OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar>

</div>

<p>

You Selected date:

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

</p>

<p>

Today&#39;s date:

<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>

</p>

<p>

Ganpati Vactaion:

<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>

</p>

<p>

Day Remaining for Ganpati Vaction:

<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>

</p>

<p>

Days Remaining for New Year:

<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>

</p>

<p>

<asp:Button ID="btnResult" runat="server" OnClick="btnResult_Click" Text="Result"


Width="57px" />&nbsp;

<asp:Button ID="btnReset" runat="server" OnClick="btnReset_Click" Text="Reset" />

</p>

</form>

</body>

</html>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Calender.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class Calender : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void btnResult_Click(object sender, EventArgs e)

Calendar1.Caption = "SAMBARE";

Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday;

Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth;

Calendar1.TitleFormat = TitleFormat.Month;

Label2.Text = "Todays Date " + Calendar1.TodaysDate.ToShortDateString();

Label3.Text = "Ganpati Vaction Start:8-31-2022";

TimeSpan d = new DateTime(2022, 8, 31) - DateTime.Now;

Label4.Text = "Days Remaining for Ganpati vacation:" + d.Days.ToString();

TimeSpan d1 = new DateTime(2022, 12, 31) - DateTime.Now;

Label5.Text = "Days Remaining for New Year:" + d1.Days.ToString();

if(Calendar1.SelectedDate.ToShortDateString() == "8-31-2022")

Label3.Text = "<b>Ganpati Festival Start</b>";

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

if(Calendar1.SelectedDate.ToShortDateString() == "9-4-2022")

Label3.Text = "<b>Ganpati Festival End</b>";

protected void btnReset_Click(object sender, EventArgs e)

Label1.Text = " ";

Label2.Text = " ";

Label3.Text = " ";

Label4.Text = " ";

Label5.Text = " ";

Calendar1.SelectedDates.Clear();

protected void Calendar1_SelectionChanged(object sender, EventArgs e)

Label1.Text = "Your Selected Date " + Calendar1.SelectedDate.Date.ToString();

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)

if(e.Day.Date.Day==5&&e.Day.Date.Month==9)

e.Cell.BackColor = System.Drawing.Color.Yellow;

Label lbl = new Label();

lbl.Text = "<br>Teacher's Day!";

e.Cell.Controls.Add(lbl);

Image g1 = new Image();

g1.ImageUrl = "/img/td.jpg";

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

g1.Height = 20;

g1.Width = 20;

e.Cell.Controls.Add(g1); }

if(e.Day.Date.Day==13&&e.Day.Date.Month==9)

{ Calendar1.SelectedDate = new DateTime(2018, 9, 12);


Calendar1.SelectedDates.SelectRange(Calendar1.SelectedDate,
Calendar1.SelectedDate.AddDays(10));

Label lbl1 = new Label();

lbl1.Text = "<br> Ganpati!!";

e.Cell.Controls.Add(lbl1);

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

PRACTICAL: 5
Aim: Demonstrate the use of Treeview control perform following operations.

a) Treeview control and datalist

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"


Inherits="DataList.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:TreeView ID="TreeView1" runat="server">

<Nodes>

<asp:TreeNode Text="AWP" Value="AWP">

<asp:TreeNode Text="Calculator" Value="Calculator"></asp:TreeNode>

<asp:TreeNode Text="Ajax" Value="Ajax"></asp:TreeNode>

</asp:TreeNode>

<asp:TreeNode Text="EJ" Value="EJ">

<asp:TreeNode Text="Calculator" Value="Calculator"></asp:TreeNode>

<asp:TreeNode Text="EJB" Value="EJB"></asp:TreeNode>

</asp:TreeNode>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

</Nodes>

</asp:TreeView>

<br />

<asp:DataList ID="DataList1" runat="server">

<FooterTemplate>

Record

</FooterTemplate>

<HeaderTemplate>

Student Details

</HeaderTemplate>

<ItemTemplate>

<asp:Label ID="Label1" runat="server" Text="ID"></asp:Label>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<asp:Label ID="Label4" runat="server" Text='<%# Eval("sid")


%>'></asp:Label>

<br />

<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<asp:Label ID="Label5" runat="server" Text='<%# Eval("sname")


%>'></asp:Label>

<br />

<asp:Label ID="Label3" runat="server" Text="Course"></asp:Label>

&nbsp;&nbsp;&nbsp;

<asp:Label ID="Label6" runat="server" Text='<%# Eval("course")


%>'></asp:Label>

</ItemTemplate>

<SeparatorTemplate>

*********************

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

</SeparatorTemplate>

</asp:DataList>

<br />

<asp:XmlDataSource ID="XmlDataSource1" runat="server"


DataFile="~/studentdetails.xml"></asp:XmlDataSource>

</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

public partial class Default : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)

BindData();

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

protected void BindData()

DataSet d = new DataSet();

d.ReadXml(Server.MapPath("~/studentdetails.xml"));

if (d != null && d.HasChanges())

DataList1.DataSource = d;

DataList1.DataBind();

studentdetails.xml

<?xml version="1.0" encoding="utf-8" ?>

<studentDetails>

<student>

<sid>1</sid>

<sname>Manvesh</sname>

<course>TYIT</course>

</student>

<student>

<sid>2</sid>

<sname>Aysuh</sname>

<course>TYCS</course>

</student>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<student>

<sid>3</sid>

<sname>Hemant</sname>

<course>TYDS</course>

</student>

</studentDetails>

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

PRACTICAL: 6
Aim: Create Web Form to demonstrate use of Ad rotator Control.
AdRotator.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdRotator.aspx.cs"


Inherits="AdRotator.AdRotator" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1"


Width="500px" />

<asp:XmlDataSource ID="XmlDataSource1" runat="server"


DataFile="~/adds.xml"></asp:XmlDataSource>

</div>

</form>

</body>

</html>

adds.xml

<?xml version="1.0" encoding="utf-8" ?>

<Advertisements>

<Ad>

<ImageUrl>Chrysanthemum.jpg</ImageUrl>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<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>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Practical :- 7
Aim:-Create Web Form to demonstrate use User Controls.
Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"


Inherits="_Default" %>

<%@ Register src="MyUserControl.ascx" tagname="MyUserControl" tagprefix="uc1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

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

<uc1:MyUserControl ID="MyUserControl1" runat="server" />

</form>

</body>

</html>

MyUserControl.ascx

<%@ Control Language="C#" AutoEventWireup="true"


CodeFile="MyUserControl.ascx.cs" Inherits="MyUserControl" %>

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

<div>

Enter Name:

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

<br />

Enter City:

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

<br />

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<asp:Button ID="Save" runat="server" OnClick="Save_Click" Text="Button" />

<br />

<br />

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

</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;

public partial class MyUserControl : System.Web.UI.UserControl

protected void Page_Load(object sender, EventArgs e)

protected void Save_Click(object sender, EventArgs e)

Label1.Text = "Your Name is " + txtName.Text + " and You are from " + txtCity.Text;

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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>

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

<div>

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"


Width="279px"></asp:TextBox>

<br />

<br />

<br />

<asp:ListBox ID="ListBox1" runat="server" Height="118px"


Width="179px"></asp:ListBox>

<br />

<br />

<br />

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

</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;

public partial class Prac6a : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

SqlConnection con = new SqlConnection("Data Source=.;Initial


Catalog=Manvesh;Integrated Security=True");

con.Open();

SqlCommand cmd = new SqlCommand(TextBox1.Text, con);

SqlDataReader reader = cmd.ExecuteReader();

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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>

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

<div>

Customer Details<br />

<br />

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

<br />

<br />

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Display


Records" />

</div>

</form>

</body>

</html>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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)
{

protected void Button1_Click(object sender, EventArgs e)


{
SqlConnection con = new SqlConnection("Data Source=.;Initial
Catalog=TYIT170;Integrated Security=True");
SqlCommand cmd = new SqlCommand("select CUS_NAME,CUS_PIN from customer",
con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
Label1.Text += reader["CUS_NAME"].ToString() + "<br>" + " " +
reader["CUS_PIN"].ToString() + "<br>";
}
reader.Close();
con.Close();
}
}
}

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Practical:- 10

Aim:- Demonstrate the use of Datalist link control.


prac6c.aspx
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 _6a : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
SqlConnection con = new SqlConnection("Data Source=.;Initial
Catalog=TYIT170;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand(TextBox1.Text, con);
SqlDataReader reader = cmd.ExecuteReader();
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();
}
}
}

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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>

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

<div>

<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>

<br />

<br />

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

<br />

<br />

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Get


Pincode" />

</div>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

</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;

public partial class Prac7b : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

if(IsPostBack==false)

SqlConnection con = new SqlConnection("Data Source =.; Initial Catalog = Manvesh;


Integrated Security = True");

con.Open();

SqlCommand cmd = new SqlCommand("select city,pincode from customer_detail1",


con);

SqlDataReader reader = cmd.ExecuteReader();

ListBox1.DataSource = reader;

ListBox1.DataTextField = "city";

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

ListBox1.DataValueField = "pincode";

ListBox1.DataBind();

protected void Button1_Click(object sender, EventArgs e)

Label1.Text = ListBox1.SelectedValue;

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Practical:-12

Aim:- Create a web application for inserting and deleting record from a
database. (Using Execute-Non Query).

ExecuteNonQuery.aspx

<%@ Page Language="C#" AutoEventWireup="true"


CodeBehind="ExecuteNonQuery.aspx.cs" Inherits="prac7c.ExecuteNonQuery" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:Label ID="Label1" runat="server" Text="Person_id"></asp:Label>

&nbsp;<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<br />

<br />

<asp:Label ID="Label2" runat="server" Text="Fname"></asp:Label>

&nbsp;<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

<br />

<br />

<asp:Label ID="Label3" runat="server" Text="Lname"></asp:Label>

&nbsp;<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

<br />

<br />

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<asp:Label ID="Label4" runat="server" Text="city"></asp:Label>

&nbsp;<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>

<br />

<br />

<asp:Label ID="Label4" runat="server" Text="State"></asp:Label>

&nbsp;<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>

<br />

<br />

<asp:Label ID="Label5" runat="server" Text="Zip Code"></asp:Label>

&nbsp;<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>

<br />

<br />

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Insert"


/>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Delete"


/>

<br />

<br />

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

</div>

</form>

</body>

</html>

ExecuteNonQuery.aspx.cs

using System;

using System.Collections.Generic;

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

using System.Configuration;

using System.Data.SqlClient;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace prac7c

{ public partial class ExecuteNonQuery : System.Web.UI.Page

{ protected void Page_Load(object sender, EventArgs e) { }

protected void Button1_Click(object sender, EventArgs e)

{ string connStr = "Data Source=.;Initial Catalog=Manvesh;Integrated


Security=True";

SqlConnection con = new SqlConnection(connStr);

string InsertQuery = "insert into EmployeeDetails values (@PERSON_ID,


@FNAME, @LNAME,@CITY, @STATE, @ZIP_CODE)";

SqlCommand cmd = new SqlCommand(InsertQuery, con);

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.ExecuteNonQuery(); Label6.Text = "Record Inserted Successfuly."; con.Close();

protected void Button2_Click(object sender, EventArgs e)

{ string connStr = "Data Source=.;Initial Catalog=Manvesh;Integrated Security=True";

SqlConnection con = new SqlConnection(connStr);

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

string InsertQuery = "delete from EmployeeDetails where NAME=@NAME";

SqlCommand cmd = new SqlCommand(InsertQuery, con);

cmd.Parameters.AddWithValue("@NAME",TextBox3.Text);

cmd.ExecuteNonQuery();

con.Open();

Label1.Text = "Record Deleted Successfuly.";

con.Close();

} } }

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<table width="50%"><tr><td width="50%" valign="top">

<b>Employee Details:</b><br /><br />

<table>

<tr><td>Name:

<asp:Textbox id="txtName" runat="server"/></td></tr>

<tr><td>Department:

<asp:Textbox id="txtDept" runat="server"/></tr>

<tr><td>Location:

<asp:Textbox id="txtLocation" runat="server"/></td></tr>

<tr><td align="right">

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Write into


XML File" />

</td></tr></table></td>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

<td width="50%" valign="top">Read XML File :

<asp:Button id="btnReadXml" text="Read XML File" runat="server"

onclick="btnReadXml_Click"/><br/>

<asp:label id="lblXml" runat="server"/></td></tr>

</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;

public partial class _Default : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void btnReadXml_Click(object sender, EventArgs e)

ReadXmlFile(Server.MapPath("EmployeeDetails.xml"));

protected void ReadXmlFile(string xmlFile)

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

string parentElementName = "";

string childElementName = "";

string childElementValue = "";

bool element = false;

lblXml.Text = "";

XmlTextReader xmlReader = new XmlTextReader(xmlFile);

while (xmlReader.Read())

if (xmlReader.NodeType == XmlNodeType.Element)

if (element)

parentElementName = parentElementName + childElementName + "<br/>";

element = true;

childElementName = xmlReader.Name;

else if (xmlReader.NodeType == XmlNodeType.Text | xmlReader.NodeType ==


XmlNodeType.CDATA)

element = false;

childElementValue = xmlReader.Value;

lblXml.Text = lblXml.Text + "<b>" + parentElementName + "<br/>" +


childElementName + "</b><br/>" + childElementValue;

parentElementName = "";

childElementName = ""; }

} xmlReader.Close();

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

protected void Button1_Click(object sender, EventArgs e)

{ XmlDocument xmlEmloyeeDoc = new XmlDocument();

xmlEmloyeeDoc.Load(Server.MapPath("~/EmployeeDetails.xml"));

XmlElement ParentElement = xmlEmloyeeDoc.CreateElement("Details");

XmlElement Name = xmlEmloyeeDoc.CreateElement("Name");

Name.InnerText = txtName.Text;

XmlElement Department = xmlEmloyeeDoc.CreateElement("Department");

Department.InnerText = txtDept.Text;

XmlElement Location = xmlEmloyeeDoc.CreateElement("Location");

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>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

OUTPUT:

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

PRACTICAL:- 13

Aim:- Create a web application demonstrate use of various Ajax Controls

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>

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

<div>

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

<br />

<asp:Timer ID="Timer1" runat="server" Interval="1000"


OnTick="Timer1_Tick">

</asp:Timer>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

</body>

</html>

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

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

public partial class Default : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected void Timer1_Tick(object sender, EventArgs e)

Label1.Text = System.DateTime.Now.ToString();

Output:-

Created By:- PRATIK SINGH Roll No.: 162


T.Y.B.Sc.I.T Advance Web Programming

Created By:- PRATIK SINGH Roll No.: 162

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy