ASP C# practical programs
ASP C# practical programs
Date: __________
Certificate
This is to certify that Mr./Miss___________________________________ seat no __________
of TYBSc IT Semester ____ has completed the practical work in the subject of
“___________________________________” during the academic year 2020 – 21 under the
guidance of Prof. _____________________________________ being the partial requirement for
the fulfilment of the curriculum of Degree of Bachelor of Information Technology, University of
Mumbai.
College Seal
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
INDEX
Sr. No. Practical’s Date Sign.
1. SIMPLE PROGRAMS WITH C#:
a. Write a console application that obtain four int values
1. from user and display the product. hint: you may recall
that the Convert.ToDouble() command was used to
convert from a string to an int is Convert.ToInt32().
Object oriented programs with c#.
2. a. Program Using Classes.
3.
4.
5.
6.
7.
8.
9.
10.
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, b, c, d, e;
Console.WriteLine("Enter First Number: ");
a = Convert.ToInt32(Console.ReadLine());
e = a * b * c * d;
Console.WriteLine("The Product Of A Given Number: "+e);
Console.ReadKey();
}
}
}
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
b. If you have two integers stored in variable var1 and var2, what boolean test can
you perform to see if one or the other (but not both) is greater than 10?
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int var1, var2;
Console.WriteLine("Enter Two Numbers: ");
var1 = Convert.ToInt16(Console.ReadLine());
var2 = Convert.ToInt16(Console.ReadLine());
if (var1 > 10 || var2 > 10)
{
if (var1 > var2)
{
Console.WriteLine(var1 + " Is Greater Than " + var2);
}
else
{
Console.WriteLine(var2 + " Is Greater Than " + var1);
}
}
else
{
Console.WriteLine("Enter A Number Which Is Greater Than 10...!!!");
}
Console.ReadKey();
}
}
}
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
c. Write A Console Application That Include The Logic From Exercise 1, Obtains
Two Numbers From The User, And Display Them, But Rejects Any Input
Where Both Numbers Are Greater Than 10 And Asks For Two New Numbers.
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int var1, var2;
abc:
Console.WriteLine("Enter Two Numbers: ");
var1 = Convert.ToInt16(Console.ReadLine());
var2 = Convert.ToInt16(Console.ReadLine());
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
d. Write a console application that places double quotation marks around each
word in a string.
Source Code:
using System;
class doubleQuote
{
static void Main(string[] args)
{
start:
string myString;
char[] separator = { ' ' };
Console.WriteLine("Type any string please");
myString = Console.ReadLine();
string[] myWords;
myWords = myString.Split(separator);
Console.WriteLine();
Console.ReadKey();
Console.Clear();
goto start;
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
namespace PRAC1._5
{
class Program
{
public static void Main(String[] args)
{
Console.WriteLine(""+args[0]);
Console.WriteLine(""+args[1]);
Console.ReadKey();
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
struct Student
{
int stud_id;
string stud_name, course_name, stud_dob;
public Student(int i, string j, string k, string l)
{
stud_id = i;
stud_name = j;
course_name = k;
stud_dob = l;
}
public void Display()
{
Console.WriteLine("{0} {1} {2} {3}", stud_id,
stud_name, course_name, stud_dob);
}
}
class Program
{
static void Main()
{
Student[] ob1 = new Student[3]; //array of structure created 3 element
for (int a = 0; a < 3; a++)
{
Console.Write("enter the student id =");
int id = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the student name =");
string str = Console.ReadLine();
Console.Write("enter the course name =");
string str1 = Console.ReadLine();
Console.Write("Enter the student dob =");
string str2 = Console.ReadLine();
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
public static int fibonacci(int n)
{
int a = 0;
int b = 1;
for (int i = 0; i < n; i++)
{
int temp = a;
a = b;
b = temp + b;
}
return a;
}
static void Main(string[] args)
{
int r;
abc:
Console.WriteLine("Enetr The Length Of Fibonacci Series: ");
r = Convert.ToInt16(Console.ReadLine());
for (int i = 0; i < r; i++)
{
Console.Write(" " + fibonacci(i));
}
Console.ReadKey();
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
class pattern
{
public static void Main()
{
int x;
for(int i=1;i<=x;i++)
{
for(int j=1;j<=i;j++)
{
Console.Write(i+ " ");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
B.
Source Code:
using System;
class pattern
{
public static void Main()
{
int x;
for(int i=1;i<=x;i++)
{
for(int j=x;j>=i;j--)
{
Console.Write(" " + "$" + " ");
}
Console.WriteLine();
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
C.
Source Code:-
using System;
class pattern1
{
public static void Main()
{
int x;
for(int i=1;i<=x;i++)
{
for(int j=x;j>i;j--)
{
Console.Write(" ");
}
for(int k=1;k<=i;k++)
{
Console.Write(i+" ");
}
Console.WriteLine();
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Sourcecode:
using System;
class edit
{
public bool Prime(int x)
{
int flag=0;
bool r;
for(int i=2;i<x;i++)
{
if(x%i==0)
{
flag=1;
break;
}
else
{
flag=0;
}
}
if(flag==0)
r=true;
else
r=false;
return r;
}
public static void Main()
{
int i;
bool result;
Console.WriteLine("Enter the number:");
i=int.Parse(Console.ReadLine());
edit obj=new edit();
result=obj.Prime(i);
Console.WriteLine(result);
}
}
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static bool IsPrimeNumber(int num)
{
bool bPrime = true;
int factor = num / 2;
int i = 0;
for (i = 2; i <= factor; i++)
{
if ((num % i) == 0)
bPrime = false;
} return bPrime;
}
static void Main(string[] args)
{
int i,r;
Console.WriteLine("Enteer Length: ");
r = Convert.ToInt16(Console.ReadLine());
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter A Number: ");
int num = int.Parse(Console.ReadLine());
int rev = 0, temp = 0, sum = 0;
while (num > 0)
{
temp = num % 10;
rev = rev * 10 + temp;
num = num / 10;
sum = sum + temp;
}
Console.WriteLine("Reverse Number Is: " + rev);
Console.WriteLine("Sum Of The Digits Is: " + sum);
Console.ReadKey();
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
char c;
Console.Write("Enter Any Charecter: ");
c = Convert.ToChar(Console.ReadLine());
switch (c)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U': Console.Write("'"+c+"' Is A Vowel...!!!");
break;
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
int[] myArray = { 20, 21, 22, 23 };
foreach (int m in myArray)
{
Console.Write(" " + m);
}
Console.ReadLine();
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
namespace ConsoleApplication1
{
class Abc {
public void Show() {
Console.WriteLine("Show called from class Abc");
}
}
class Test {
public static void Main() {
Abc a = new Abc();
a.Show();
Console.Read();
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
i) Function Overloading
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication12
{
class A
{
private int k;
public void display()
{
k = 1000;
Console.WriteLine("The Value Of K Is: " + k);
}
public void display(int p)
{
k = p;
Console.WriteLine("The Value Of K Is: "+k);
}
}
class B
{
static void Main(string[] args)
{
A x = new A();
x.display();
x.display(3413);
Console.ReadKey();
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
A. Single Inheritance:
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class shape
{
protected int width, height;
public void setwidth(int w)
{
width = w;
}
public void setHeight(int h)
{
height = h;
}
}
class Rectangle : shape
{
public int getArea()
{
return width * height;
}
}
class RectangleTest
{
static void Main(string[] args)
{
Rectangle rect = new Rectangle();
rect.setHeight(7);
rect.setwidth(5);
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
B. Multi-Level Inheritance:
Source Code:
using System;
class Abc
{
public void Show()
{
Console.WriteLine("Displayed from main base class Abc");
}
}
class Bbc : Abc
{
public void Display()
{
Console.WriteLine("Displayed from sub base class Bbc");
}
}
class Pqr : Bbc
{
public void ShowMe()
{
Console.WriteLine("Displayed from derived class Pqr");
}
}
class Test
{
public static void Main()
{
Pqr p = new Pqr();
p.Show();
p.Display();
p.ShowMe();
Console.Read();
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
C. Heirarchical Inheritance:
Source Code:
using System;
class HeadOffice
{
public void HeadOfficeAddress()
{
Console.WriteLine("Head Office Address");
}
}
class BranchOffice1:HeadOffice
{
public void BranchOfficeAddress()
{
Console.WriteLine("Branch1 Office Address");
}
}
class BranchOffice2 : HeadOffice
{
public void BranchOfficeAddress()
{
Console.WriteLine("Branch2 Office Address");
}
}
class Test
{
static void Main(string[] args)
{
HeadOffice ho = new HeadOffice();
ho.HeadOfficeAddress();
BranchOffice1 bo1 = new BranchOffice1();
bo1.BranchOfficeAddress();
BranchOffice2 bo2 = new BranchOffice2();
bo2.BranchOfficeAddress();
Console.ReadKey();
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Source Code:
using System;
class Test
{
public Test()
{
Console.WriteLine("Default Constructor of Test class");
}
public Test(int x)
{
Console.WriteLine("Parameterized Constructor of Test class");
}
public Test(string text)
{
Console.WriteLine("Parameterized Constructor of Test class with a
string parameter");
}
static Test()
{
Console.WriteLine("Static Constructor of Test class");
}
}
class Demo
{
public static void Main()
{
Test t = new Test();
Test t1 = new Test(10);
Test t2 = new Test("abc");
Console.Read();
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
iv) Intefaces.
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public interface IEmployee
{
void DisplayEmployeeDetails();
}
public interface ICompany
{
void DisplayEmpDetails();
}
public class Employee : IEmployee, ICompany
{
void ICompany.DisplayEmpDetails()
{
Console.WriteLine("ICompany Employee No.: 009");
}
void IEmployee.DisplayEmployeeDetails()
{
Console.WriteLine("ICompany Employee Name: xyz");
}
}
class Program
{
static void Main(string[] args)
{
IEmployee iemp = new Employee();
iemp.DisplayEmployeeDetails();
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
A. Delegates:
Source Code:
using System;
//Declare Delegate
public delegate int MyDel(int x,int y);
class Abc
{
public int Add(int a, int b)
{
int c = a + b;
return c;
}
public static int Sub(int x, int y)
{
int z = x - y;
return z;
}
}
class Test
{
public static void Main()
{
Abc a1 = new Abc();
//Delegate initialisation
MyDel m1 = new MyDel(a1.Add);
//Delegate invocation
Console.WriteLine(""+m1(10, 20));
MyDel m2 = new MyDel(Abc.Sub);
//Delegate invocation
Console.WriteLine("" + m2(100, 76));
Console.Read();
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
B. Events:
Source Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
3. User left click on "ASP.NET Empty Web Site (list item)" in "New Web Site"
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
7. User left click on "_Add (text)" in "Add New Item - E:\KHAN\Study\TYIT sem V\
WebSite4\"
8.
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
3. ASP.NET application using server controls to get the user data as roll
number(listbox), name(textbox), password(textbox), gender(radiobutton),
hobbies(checkboxlist), dob(calender) show above data on another form.
Form Layout:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
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>
<form id="form1" runat="server">
<div>
Roll No :- Name:-
TYBSc(IT) 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;
}
protected void Button1_Click(object sender, EventArgs e)
{
String name, rn, pwd, gd, hb, dob;
name = Server.UrlEncode(Name.Text);
rn = Server.UrlEncode(Rno.Text);
int rno=Convert.ToInt32(rn);
pwd = Server.UrlEncode(Pwd.Text);
gd = Server.UrlEncode(Gd.Text);
hb = Server.UrlEncode(Hb.Text);
dob=Server.UrlEncode(Dob.SelectedDate.Date.ToString());
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Read.aspx(Layout):
Read.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Read.aspx.cs"
Inherits="Read" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
</form>
</body>
</html>
Read.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<h1 style="color:Lime" >Heading1</h1>
<h2>Heading2</h2>
</body>
</html>
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
Default2.aspx :
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<style type="text/css">
h2 {color:Orange; font-family:Arabic Typesetting; font-size:30pt};
</style>
</head>
<body>
<h1>Heading1</h1>
<h2>Heading2</h2>
</body>
</html>
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
Default2.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" />
</head>
<body>
<h1>Heading1</h1>
<h2>Heading2</h2>
</body>
</html>
StyleSheet.css:
body
{
background:cyan;
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
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>
<form id="form1" runat="server">
<div>
</div>
<asp:Button ID="Button1" runat="server" Height="39px" onclick="Button1_Click"
style="z-index: 1; left: 86px; top: 15px; position: absolute"
Text="SELECT COUNTRY" Width="168px" />
<br />
<br />
<asp:Label ID="Label1" runat="server"
style="z-index: 1; left: 130px; top: 76px; position: absolute" Text="Label"
Visible="False"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Your Selection Is: ""></asp:Label>
<br />
<br />
<asp:Label ID="Label3" runat="server"
Roll No :- Name:-
TYBSc(IT) 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;
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedItem.Text;
}
}
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
<html xmlns="http://www.w3.org/1999/xhtml">
</div>
</form>
</body>
</html>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
User
Name:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
*<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Name cannot be left
blank"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ErrorMessage="Username must be between 4 and 64 characters"
ControlToValidate="TextBox1"
ValidationExpression="^[\s\S]{4,64}$"></asp:RegularExpressionValidator>
<br />
Password: &nbs
p;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
*<br />
Confirm Password: <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
*<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox2" ControlToValidate="TextBox3"
ErrorMessage="Passwords do not match"></asp:CompareValidator>
<br />
Email
ID: &nbs
p; <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
*<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="TextBox4" ErrorMessage="Not a valid email
id"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></
asp:RegularExpressionValidator>
<br />
Age: &n
bsp;
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
*<asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToValidate="TextBox5" ErrorMessage="Age must be >18"
ValueToCompare="18"></asp:CompareValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
</div>
</form>
</body>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
</html>
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</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;
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Global.aspx:
<%@ Application Language="C#" %>
<script runat="server">
public static int count = 0;
void Application_Start(object sender, EventArgs e)
{
Application["myCount"] = count;
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
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>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Roll No :- Name:-
TYBSc(IT) 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;
}
protected void Button1_Click(object sender, EventArgs e)
{
String name = Server.UrlEncode(TextBox1.Text);
String num1 = Server.UrlEncode(TextBox2.Text);
String num2 = Server.UrlEncode(TextBox3.Text);
int n1 = Convert.ToInt16(num1);
int n2 = Convert.ToInt16(num2);
int n3;
if (n1 > n2)
n3 = n1;
else
n3 = n2;
String nn1 =Server.UrlEncode(Convert.ToString(n1));
string nn2 = Server.UrlDecode(Convert.ToString(n2));
String nn3 = Server.UrlEncode(Convert.ToString(n3));
String Url = "Result.aspx?" + "nm=" + name + "&n1=" + num1 + "&n2=" + num2 +
"&grt=" + nn3;
Response.Redirect(Url);
}
}
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Result.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Result.aspx.cs"
Inherits="Result" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Result.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
}
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
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>
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:Menu>
</div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
</div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Form Layout:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DTH.aspx.cs"
Inherits="DTH" %>
<!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>
<asp:Label ID="Label1" runat="server" Text="DTH SECTION"></asp:Label>
<br />
<br />
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
</div>
</form>
</body>
</html>
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
MasterPage.Master:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:LinkButton ID="LinkButton1" runat="server"
PostBackUrl="~/WebForm1.aspx">C#</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server"
PostBackUrl="~/WebForm2.aspx">NS</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server"
PostBackUrl="~/WebForm3.aspx">ST</asp:LinkButton>
<br />
<br />
<br />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<br />
<br />
<br />
</div>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
</form>
</body>
</html>
MasterPage.Master.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
}
}
}
C#.aspx:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
NS.aspx:
ST.aspx:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
12. Develop a ASP>NET application to insert and delete student record (RollNo,
FName, Marks, gender, Address).
Form Layout:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication23.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
<br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<br />
</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.Data;
using System.Data.SqlClient;
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
namespace WebApplication23
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}
catch
{
Label4.Text = "Problem in Database Connection";
}
finally
{
conn.Close();
}
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
catch
{
Label4.Text = "Problem in Database Connection";
}
finally
{
conn.Close();
}
}
}
catch
{
Label4.Text = "Problem in Database Connection";
}
finally
{
conn.Close();
}
}
try
{
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
conn.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
TextBox2.Text = sdr["FName"].ToString();
TextBox3.Text = sdr["Address"].ToString();
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
finally
{
conn.Close();
}
}
}
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
i) GridView:
Form Layout:
Default.aspx:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="RollNo" HeaderText="RollNo"
SortExpression="RollNo" />
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name" />
<asp:BoundField DataField="PhoneNo" HeaderText="PhoneNo"
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
SortExpression="PhoneNo" />
<asp:BoundField DataField="Gender" HeaderText="Gender"
SortExpression="Gender" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TYITConnectionString %>"
SelectCommand="SELECT * FROM [tyit] ORDER BY
[Name]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
ii) DetailsView
Form Layout:
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>
<form id="form1" runat="server">
<div>
<br />
<asp:Label ID="Label1" runat="server" Text="Enter RollNo"></asp:Label>
<asp:TextBox ID="TxtRlno" runat="server"></asp:TextBox>
<br />
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="width: 39px" Text="Find" />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px"
Width="125px">
</asp:DetailsView>
<br />
<br />
<br />
</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.Data;
using System.Data.SqlClient;
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=AYESHA-
PC;Initial Catalog=TYIT;Integrated Security=SSPI");
con.Open();
Label2.Text = "Details of "+TxtRlno.Text+" are as follows";
String query = ("select * from tyit where RollNo =") + TxtRlno.Text;
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
da.Fill(ds);
DetailsView1.DataSource=ds;
DetailsView1.DataBind();
con.Close(); }}
Output:-
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
iii) ListView
Form Layout:
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
<td>
<asp:TextBox ID="GenderTextBox" runat="server" Text='<%# Bind("Gender")
%>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-
color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
<asp:TextBox ID="RollNoTextBox" runat="server" Text='<%# Bind("RollNo")
%>' />
</td>
<td>
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'
/>
</td>
<td>
<asp:TextBox ID="PhoneNoTextBox" runat="server" Text='<%#
Bind("PhoneNo") %>' />
</td>
<td>
<asp:TextBox ID="GenderTextBox" runat="server" Text='<%# Bind("Gender")
%>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color:#DCDCDC;color: #000000;">
<td>
<asp:Label ID="RollNoLabel" runat="server" Text='<%# Eval("RollNo") %>' />
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
</td>
<td>
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td>
<asp:Label ID="PhoneNoLabel" runat="server" Text='<%# Eval("PhoneNo")
%>' />
</td>
<td>
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse:
collapse;border-color: #999999;border-style:none;border-width:1px;font-family:
Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color:#DCDCDC;color: #000000;">
<th runat="server">
RollNo</th>
<th runat="server">
Name</th>
<th runat="server">
PhoneNo</th>
<th runat="server">
Gender</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #CCCCCC;font-
family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
<td>
<asp:Label ID="RollNoLabel" runat="server" Text='<%# Eval("RollNo") %>' />
</td>
<td>
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td>
<asp:Label ID="PhoneNoLabel" runat="server" Text='<%# Eval("PhoneNo")
%>' />
</td>
<td>
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TYITConnectionString %>"
SelectCommand="SELECT * FROM [tyit]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
i) LINQ TO OBJECT
Default.aspx.cs:
using System;
using System.Xml.Linq;
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Customers.xml:
Default.aspx.cs;
using System;
using System.Xml.Linq;
}
protected void cmdShowAll_Click(object sender, EventArgs e)
{
XDocument document = XDocument.Load(@"C:\Books.xml");
var books = from r in document.Descendants("book")
select new
{
Author = r.Element("author").Value,
Title = r.Element("title").Value,
Price = r.Element("price").Value
};
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click">
</asp:AsyncPostBackTrigger>
</Triggers>
</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;
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Default.aspx:
<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:Timer ID="Timer1" runat="server" Interval="1000" OnTick="click">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="tick" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</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;
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
<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="UpdatePanel3" runat="server">
<ContentTemplate>
<div style="background-color:#FFFFE0;padding: 20px">
<asp:Label ID="lblTime" runat="server" Font-Bold="True"></asp:Label>
<br /><br />
<asp:Button ID="Button1" runat="server" OnClick="cmdRefreshTime_Click"
Text="Start the Refresh Process" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdateProgress ID="updateProgress1" runat="server">
<ProgressTemplate>
<div style="font-size: xx-small">
<asp:Image ID="Image1" runat="server" Height="140px"
ImageUrl="~/Please_wait (1).gif" Width="539px" />
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
</body>
</html>
Default.aspx.cs;
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
}
Output:
Roll No :- Name:-
TYBSc(IT) Advance Web Programming
Roll No :- Name:-