715 - Sanket Dalvi - 1 To 5

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 94

Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.

IT
Roll No:- 715 Div:- A

PRACTICAL NO:- 1

Practical 1(A):-

Aim:- Create Application that obtains four int values from user and displays the
product.

Source Code:-

using System;

public class Program

public static void Main(string[] args)

int x, y, z, p;

Console.WriteLine("Enter no1:");

x=int.Parse(Console.ReadLine());

Console.WriteLine("Enter no2:");

y=int.Parse(Console.ReadLine());

Console.WriteLine("Enter no3:");

z=int.Parse(Console.ReadLine());

Console.WriteLine("Enter no4:");

p=int.Parse(Console.ReadLine());

int q = x*y*z*p;

Console.WriteLine("Product is:");

Console.WriteLine(q);

Console.ReadLine();

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 1(B):-

Aim:- Create an application to demonstrate string operations.

Source Code:-

Program for webForm1.aspx:-

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


CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication5.WebForm1" %>

<!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:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />

<asp:Button ID="Button1" runat="server" Text="Button"


onclick="Button1_Click" /><br />

<asp:Label ID="Label1" runat="server" Text="String


length:"></asp:Label><br />

<asp:Label ID="Label2" runat="server"


Text="substring:"></asp:Label><br />

<asp:Label ID="Label3" runat="server" Text="upper


string:"></asp:Label><br />

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

<asp:Label ID="Label4" runat="server" Text="lower


string:"></asp:Label><br />

<asp:Label ID="Label5" runat="server" Text="reverse


string:"></asp:Label><br />

<asp:Label ID="Label6" runat="server" Text="pad left:"></asp:Label><br />

<asp:Label ID="Label7" runat="server" Text="pad


right:"></asp:Label><br />

<asp:Label ID="Label8" runat="server" Text="insert:"></asp:Label><br />

<asp:Label ID="Label9" runat="server" Text="remove:"></asp:Label><br />

<asp:Label ID="Label10" runat="server"


Text="repalce:"></asp:Label><br />

<asp:Label ID="Label11" runat="server"


Text="startwith:"></asp:Label><br />

<asp:Label ID="Label12" runat="server" Text="end


with:"></asp:Label><br />

<asp:Label ID="Label13" runat="server"


Text="IndexOf:"></asp:Label><br />

<asp:Label ID="Label14" runat="server"


Text="LastIndexOf:"></asp:Label><br />

<asp:Label ID="Label15" runat="server" Text="Split:"></asp:Label><br />

</div>

</form>

</body>

</html>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Program for webForm1.aspx.cs:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace WebApplication5

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

string s = TextBox1.Text;

Label1.Text = "String length:" + s.Length;

Label2.Text = "substring:" + s.Substring(3, 3);

Label3.Text = "Upper string:" + s.ToUpper();

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Label4.Text = "Lower string:" + s.ToLower();

string rev = "";

for (int i = s.Length - 1; i >= 0; i--)

rev = rev + s[i];

Label5.Text = "reverse string:" + rev.ToString();

Label6.Text = "Pad left:" + s.PadLeft(15, '@');

Label7.Text = "Pad right:" + s.PadRight(15, '@');

Label8.Text = "Insert:" + s.Insert(2, "sanket");

Label9.Text = "Remove:" + s.Remove(2, 4);

Label10.Text = "Replace:" + s.Replace("dalvi", "sanket");

Label11.Text = "StartWith:" + s.StartsWith("Pre");

Label12.Text = "Endwith:" + s.EndsWith("Pre");

Label13.Text = "IndexOf:" + s.IndexOf("ket");

Label14.Text = "LastIndexOf:" + s.LastIndexOf("lvi");

Label15.Text = "Split:" + s.Split('#');

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 1(C1):-

Aim:- Create Application that generate Fibonacci series.

Source Code:-

using System;

namespace ConsoleApplication1

public class Primenumber

public static void Main(string[] args)

int f1=0,f2=1,f3,n,co;

Console.WriteLine("Enter the number");

n=int.Parse(Console.ReadLine());

co=3;

Console.WriteLine("Fibonacci Series");

Console.WriteLine(f1 + "\t" + f2 );

while (co <= n)

f3=f1+f2;

Console.Write("\t" + f3);

f1=f2;

f2=f3;

co++;

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Console.ReadLine();

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 1(C2):-

Aim:- Create Application that test for prime numbers.

Source Code:-

using System;

public class Prime

public static void Main(string[] args)

int n, i, m=0, flag=0;

Console.Write("Enter the number : ");

n = int.Parse(Console.ReadLine());

m=n/2;

for(i = 2; i <= m; i++)

if(n % i == 0)

Console.Write("Number is not Prime.");

flag=1;

break;

if (flag==0)

Console.Write("Number is Prime.");

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 1(C3):-

Aim:- Create Application that Reverse a number and find sum of digits of a
number.

Source Code:-

using System;

public class ReverseNumber

public static void Main(string[] args)

int n, reverse=0, rem, sum=0, m;

Console.WriteLine("Enter a number: ");

n= int.Parse(Console.ReadLine());

while(n!=0)

rem=n%10;

reverse=reverse*10+rem;

m=n%10;

sum =sum+m;

n/=10;

Console.WriteLine("Reversed Number: "+reverse);

Console.WriteLine("Sum is= "+sum);

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 1(C4):-

Aim:- Check Vowel or Not.

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace isvowel

public class program

public static void Main(string[] args)

char[]v={'a','e','i','o','u'};

char ch;

Console.WriteLine("Enter the Character : ");

ch =Convert.ToChar(Console.ReadLine().ToLower());

for(int i=0;i<5;i++)

if(ch==v[i])

Console.WriteLine(ch+" is Vowel");

break;

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

else if(i==4)

Console.WriteLine(ch+" is not Vowel");

Console.ReadLine();

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 1(C5):-

Aim:- For each using array

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace foreachdemon

public class Program

public static void Main(string[] args)

int[] ch = {1,2,3,4,5};

foreach(int c in ch)

Console.Write(c+"");

Console.ReadLine();

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

PRACTICAL NO:- 2

Working with Object Oriented C# and ASP.NET

Practical 2(A):- Create simple application to demonstrate use of following


concepts

Practical 2(A1):-

Aim:- Function Overloading.

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplicationFuncOverl

public class Program

public int Area(int a, int b)

return a * b;

public int Area(int a)

return a * a;

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

public double Area(double a)

return 3.14 * a * a;

public class Program1

public static void Main(string[] args)

Program s = new Program();

int rect = s.Area(6, 7);

int square = s.Area(5);

double circ = s.Area(5.7);

Console.Write("Area of Rectangle: " + rect + "\n");

Console.Write("Area of Square: " + square + "\n");

Console.Write("Area of Circle: " + circ + "\n");

Console.ReadLine();

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 2(A2):-

Aim:- 1) Single Inheritance

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

public class Program

public static void Main(string [] args)

Teacher d = new Teacher();

d.Teach();

Student s = new Student();

s.Learn();

s.Teach();

Console.ReadLine();

class Teacher

public void Teach()

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Console.WriteLine("Teach");

class Student:Teacher

public void Learn()

Console.WriteLine("Learn");

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 2(A2):-

Aim:- 2) Multilevel Inheritance

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace multilevel

public class Mode

public void mode()

Console.WriteLine("There are Many Modes Of transport!!");

public class vehicle : Mode

public void feature()

Console.WriteLine("There are Many in Travelling!!");

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

public class inheri : vehicle

public void Noise()

Console.WriteLine("All Vehicle Create Noise!!");

public static void Main(string[] args)

inheri obj = new inheri();

obj.mode();

obj.feature();

obj.Noise();

Console.ReadLine();

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 2(A2):-

Aim:- 3) Demonstrate Hierarchical Inheritance

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace hierarchical

interface calc1

int add(int a, int b);

interface calc2

int sub(int x, int y);

interface calc3

int mul(int r, int s);

interface calc4

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

int div(int c, int d);

public class Calculation : calc1,calc2,calc3,calc4

public int result1;

public int add(int a, int b)

return result1 = a+b;

public int result2;

public int sub(int x, int y)

return result2 = x-y;

public int result3;

public int mul(int r, int s)

return result3 = r*s;

public int result4;

public int div(int c, int d)

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

return result4 = c/d;

public class Program

public static void Main(string[] args)

Calculation c = new Calculation();

c.add(8,2);

c.sub(20,10);

c.mul(5,2);

c.div(20,10);

Console.WriteLine("Multiple Inheritance Concept Using


Interface:\n");

Console.WriteLine("Addition : "+c.result1);

Console.WriteLine("Subtraction :" +c.result2);

Console.WriteLine("Multiplication :"+c.result3);

Console.WriteLine("Division :"+c.result4);

Console.ReadLine();

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 2(A2):-

Aim:- 4) Demonstrate Hybrid Inheritance.

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication2

class Program

static void Main(string[] args)

grandfather g = new grandfather();

g.truck();

dad d = new dad();

d.truck();

d.car();

son s = new son();

s.truck();

s.bike();

Console.ReadKey();

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

class grandfather

public void truck()

Console.WriteLine("TRUCK");

class dad : grandfather

public void car()

Console.WriteLine("CAR");

class son : grandfather

public void bike()

Console.WriteLine("BIKE");

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 2(A3):-

Aim:- Constructor Overloading.

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication2

class BankAccount

private int cust_id; private string cust_name; private int bal;

public BankAccount()

cust_id = 1000; cust_name = "Not yet Specified"; bal = 0;

public BankAccount(int cust_id, string cust_name, int bal)

this.cust_id = cust_id; this.cust_name = cust_name; this.bal = bal;

public BankAccount(BankAccount obj)

cust_id = obj.cust_id; cust_name = obj.cust_name;

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

bal = obj.bal;

public void ShowData()

Console.WriteLine("cust id={0},customer name={1},Bank Balance={2}",


cust_id, cust_name, bal);

class program

public static void Main(string[] args)

BankAccount a = new BankAccount();//invokes default constructor

BankAccount b = new BankAccount(411, "Sanket", 2000);//invokes


parameterised construcor

BankAccount c = new BankAccount(b);//Invokes copy contsurctor


a.ShowData();

b.ShowData();

c.ShowData();

Console.ReadLine();

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 2(A4):-

Aim:- Interfaces

Source Code:-

using System;

public interface ITransaction

string retcode();

double amtfunc();

public class Transaction : ITransaction

private string tCode;

private double amount;

public Transaction()

tCode = "";

amount = 0.0;

public Transaction(string c, double a)

tCode = c;

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

amount = a;

public double amtfunc()

return amount;

public string retcode()

return tCode;

public class Program

public static void Main()

Transaction t1 = new Transaction("Cr", 780.00);

Transaction t2 = new Transaction("Db", 400.00);

Console.WriteLine(t1.retcode());

Console.WriteLine(t2.retcode());

Console.WriteLine(t1.amtfunc());

Console.WriteLine(t2.amtfunc());

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Console.ReadLine();

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 2(B):- Create a simple application to demonstrate the use of following


concept.

Practical 2(B1):-

Aim:- Using Delegates and events

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace delegate1

class Program

public delegate void print(int value);

static void Main(string[] args)

print printDel = printNumber;

printDel(100000);

printDel(200);

printDel = printMoney;

printDel(100000);

printDel(200);

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Console.ReadLine();

public static void printNumber(int num)

Console.WriteLine("Number:{0}", num);

public static void printMoney(int money)

Console.WriteLine("Money:{0}", money);

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 2(B2):-

Part A:-

Aim:- Exception Handling

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication5

class program

static void Main(string[] args)

Console.Write("enter student name:");

string studentName = Console.ReadLine();

IList<String> studentList = FindAllStudentFromDatabase(studentName);

Console.WriteLine("total{0}:{1}",studentName,studentList.Count());

Console.ReadKey();

private static IList<String>FindAllStudentFromDatabase(string studentName)

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

IList<String>studentList=null;

return studentList;

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Part B:-

Aim:- with try and catch.

Source Code:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication5

class program

static void Main(string[] args)

Console.Write("enter student name:");

string studentName = Console.ReadLine();

try

IList<String> studentList =
FindAllStudentFromDatabase(studentName);

Console.WriteLine("total{0}:{1}", studentName, studentList.Count());

catch (Exception ex)

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Console.WriteLine("no student exist for the specified name");

Console.ReadKey();

private static IList<String>FindAllStudentFromDatabase(string studentName)

IList<String>studentList=null;

return studentList;

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

PRACTICAL NO:- 3

Working with Web Forms and Controls

Practical 3(A1):-

Aim:- Create a simple web page with various server controls to demonstrate
setting and use of their properties. (Example : AutoPostBack)

Source Code:-

Program for webform1.aspx:-

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


CodeBehind="WebForm1.aspx.cs" Inherits="_3a2_autopostback.WebForm1" %>

<!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="Principle


Amount"></asp:Label>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

<asp:Label ID="Label2" runat="server" Text="Interest


Amount"></asp:Label>

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />

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

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


onselectedindexchanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="True">

<asp:ListItem Value="1"></asp:ListItem>

<asp:ListItem>2</asp:ListItem>

<asp:ListItem>3</asp:ListItem>

<asp:ListItem>4</asp:ListItem>

<asp:ListItem>5</asp:ListItem>

</asp:DropDownList><br />

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

<asp:Button ID="Button1" runat="server" Text="calculate"


onclick="Button1_Click" />

</div>

</form>

</body>

</html>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Program for webForm1.aspx.cs:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace _3a2_autopostback

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

double P = Convert.ToDouble(TextBox1.Text);

double r = Convert.ToDouble(TextBox2.Text);

double t = Convert.ToDouble(DropDownList1.SelectedValue);

TextBox3.Text = Convert.ToString(P * (1 + r * t));

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

protected void DropDownList1_SelectedIndexChanged(object sender,


EventArgs e)

double P = Convert.ToDouble(TextBox1.Text);

double r = Convert.ToDouble(TextBox2.Text);

double t = Convert.ToDouble(DropDownList1.SelectedValue);

TextBox3.Text = Convert.ToString(P * (1 + r * t));

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 3(B):-

Aim:- Demonstrate the use of Calendar control to perform the following operation.

A) Display message in a calendar.

B) Display vacation in a calendar control.

C) Selected day in calendar using style.

D) Difference between two calendar dates.

Source Code:-

WebForm1.aspx:-

Take calendar only and consider all division tag code.

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


CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication24.WebForm1" %>

<!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:Calendar ID="Calendar1" runat="server" BackColor="White"

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

BorderColor="Black" BorderStyle="Solid" CellSpacing="1" Font-


Names="Verdana"

Font-Size="9pt" ForeColor="Black" Height="250px"


NextPrevFormat="ShortMonth"

ondayrender="Calendar1_DayRender"

onselectionchanged="Calendar1_SelectionChanged" Width="330px">

<DayHeaderStyle Font-Bold="True" Font-Size="8pt"


ForeColor="#333333"

Height="8pt" />

<DayStyle BackColor="#CCCCCC" />

<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="White" />

<OtherMonthDayStyle ForeColor="#999999" />

<SelectedDayStyle BackColor="#333399" ForeColor="White" />

<TitleStyle BackColor="#333399" BorderStyle="Solid" Font-Bold="True"

Font-Size="12pt" ForeColor="White" Height="12pt" />

<TodayDayStyle BackColor="#999999" ForeColor="White" />

</asp:Calendar>

</div>

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

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

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

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

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

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

<asp:Button ID="Button1" runat="server" Text="Button"


onclick="Button1_Click" /><br/>

</form>

</body>

</html>

Design:-

Right click on calendar -> go to properties-> event->click on DayRender.

WebUserControl1.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace WebApplication24

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

protected void Page_Load(object sender, EventArgs e)

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

protected void Calendar1_SelectionChanged(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

Calendar1.Caption = "Kalnirnay";

Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday;

Calendar1.TitleFormat = TitleFormat.Month;

Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth;

Label2.Text = "Todays date:" +


Calendar1.TodaysDate.ToShortDateString();

Label3.Text = "Ganpati vacation start: 09-10-2021";

TimeSpan d = new DateTime(2021, 9, 10) - DateTime.Now;

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

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

Label5.Text = "Days remaing for new year:" + d1.Days.ToString();

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

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

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

Label lb1 = new Label();

lb1.Text = "<br>Teacher;s day:";

e.Cell.Controls.Add(lb1);

Image g1 = new Image();

g1.ImageUrl = "youtube.png";

g1.Height = 20;

g1.Width = 20;

e.Cell.Controls.Add(g1);

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

Calendar1.SelectedDate = new DateTime(2021, 9, 10);

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

Label lbl1 = new Label();

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

e.Cell.Controls.Add(lbl1);

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

PRACTICAL NO:- 4

Working with Form Controls

Practical 4(A):-

Aim:- Create a Registration form to demonstrate use of various Validation


controls.

Source Code:-

WebForm1.aspx

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


CodeBehind="WebForm1.aspx.cs" Inherits="validation.WebForm1" %>

<!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 style="width: 100%;">

<tr>

<td>

Name

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</td>

<td>

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

</td>

<td>

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

ErrorMessage="Enter Name"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator>

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

ErrorMessage="Enter Characters only"


ControlToValidate="TextBox1" ValidationExpression="[a-zA-Z]
+"></asp:RegularExpressionValidator>

</td>

</tr>

<tr>

<td>

Roll No

</td>

<td>

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

</td>

<td>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

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

ErrorMessage="Enter no"
ControlToValidate="TextBox2"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td>

Age

</td>

<td>

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

</td>

<td>

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

ErrorMessage="Enter Age"
ControlToValidate="TextBox3"></asp:RequiredFieldValidator>

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


ErrorMessage="Enter age in between 18-25" MaximumValue="25"
MinimumValue="18" ControlToValidate="TextBox3"></asp:RangeValidator>

</td>

</tr>

<tr>

<td>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Contact

</td>

<td>

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

</td>

<td>

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

ErrorMessage="Enter Contact"
ControlToValidate="TextBox4"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td>

Email

</td>

<td>

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

</td>

<td>

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

ErrorMessage="Enter E-mail"
ControlToValidate="TextBox5"></asp:RequiredFieldValidator>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

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

ErrorMessage="Enter Correct Email id"


ControlToValidate="TextBox5"

ValidationExpression="\w+([-+.']\w+)@\w+([-.]\w+)\.\w+
([-.]\w+)*"></asp:RegularExpressionValidator>

</td>

</tr>

<tr>

<td>

Password

</td>

<td>

<asp:TextBox ID="TextBox6" runat="server"


TextMode="Password"></asp:TextBox>

</td>

<td>

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

ErrorMessage="Enter Password"
ControlToValidate="TextBox6"></asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Re-type Password

</td>

<td>

<asp:TextBox ID="TextBox7" runat="server"


TextMode="Password"></asp:TextBox>

</td>

<td>

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

ErrorMessage="Re-type Password"
ControlToValidate="TextBox7"></asp:RequiredFieldValidator>

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

ErrorMessage="Enter Correct Password"


ControlToCompare="TextBox6"
ControlToValidate="TextBox7"></asp:CompareValidator>

</td>

</tr>

<tr>

<td>

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

</td>

<td>

<asp:Button ID="Button2" runat="server" Text="Clear" />

</td>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</tr>

<tr>

<td>

<asp:ValidationSummary ID="ValidationSummary1"
runat="server" />

</td>

</tr>

</table>

</div>

</form>

</body>

</html>

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 4(B):-

Aim:- Create Web Form to demonstrate use of Adrotator Control.

Source Code:-

Web form:-

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


CodeBehind="WebForm_adrotator.aspx.cs"
Inherits="WebApplication15.WebForm_adrotator" %>

<!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="form2" runat="server">

<div>

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


DataSourceID="XmlDataSource1" />

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


DataFile="~/XMLFile1.xml">

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</asp:XmlDataSource>

</div>

</form>

</body>

</html>

Xml file:

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

<Advertisements>

<Ad>

<ImageUrl>flip0.png</ImageUrl>

<NavigateUrl>http://www.1800flowers.com</NavigateUrl>

<AlternateText>

Order flowers, roses, gifts and more

</AlternateText>

<Impressions>1</Impressions>

<Keyword>flowers</Keyword>

</Ad>

<Ad>

<ImageUrl>flip1.png</ImageUrl>

<NavigateUrl>http://www.babybouquets.com.au</NavigateUrl>

<AlternateText>Order roses and flowers</AlternateText>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

<Impressions>1</Impressions>

<Keyword>gifts</Keyword>

</Ad>

<Ad>

<ImageUrl>flip2.png</ImageUrl>

<NavigateUrl>http://www.flowers2moscow.com</NavigateUrl>

<AlternateText>Send flowers to Russia</AlternateText>

<Impressions>2</Impressions>

<Keyword>russia</Keyword>

</Ad>

</Advertisements>

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 4(C):-

Aim:- Create Web Form to demonstrate use of User Controls.

Source Code:-

WebForm1.aspx

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


CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication17.WebForm1" %>

<%@Register Src="~/WebUserControl1.ascx" TagPrefix="uc1"


TagName="Student" %>

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

<uc1:Student ID="WebUserControl1" runat="server" /></br>

<uc1:Student ID="Student1" runat="server" /></br>

<uc1:Student ID="clr" runat="server" /></br>

<uc1:Student ID="abc" runat="server" /></br>

</div>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</form>

</body>

</html>

Go add item select web user Control.

WebUserControl1.aspx

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


CodeBehind="WebUserControl1.ascx.cs"
Inherits="WebApplication17.WebUserControl1" %>

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

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

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

WebUserControl1.aspx.cx

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

namespace WebApplication17

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

Response.Redirect("https://www.google.com/");

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

PRACTICAL NO:- 5

Working with Navigation, Beautification and Master Page

Practical 5(A):-

Aim:- Create Web Form to Demonstrate use of Website Navigation controls and
site map.

Source Code:-

WebForm1.aspx

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


CodeBehind="WebForm1.aspx.cs" Inherits="about_view_.WebForm1" %>

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

<asp:TreeView ID="TreeView2" runat="server"


DataSourceID="SiteMapDataSource1">

</asp:TreeView>

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />

</div>

</form>

</body>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</html>

Page1.aspx

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


CodeBehind="Page1.aspx.cs" Inherits="about_view_.Page1" %>

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

Home

</div>

</form>

</body>

</html>

Page2.aspx

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


CodeBehind="Page2.aspx.cs" Inherits="about_view_.Page2" %>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

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

about

</div>

</form>

</body>

</html>

Page3.aspx

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


CodeBehind="Page3.aspx.cs" Inherits="about_view_.Page3" %>

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

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

<title></title>

</head>

<body>

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

<div>

services

</div>

</form>

</body>

</html>

Page4.aspx

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


CodeBehind="Page4.aspx.cs" Inherits="about_view_.Page4" %>

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

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

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

<div>

contact

</div>

</form>

</body>

</html>

Web.sitemap

Goto additem->web->site map

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

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

<siteMapNode url="Page1.aspx" title="Home" description="home">

<siteMapNode url="Page2.aspx" title="About" description="about" >

<siteMapNode url="Page4.aspx" title="Contact" description="contact" />

</siteMapNode>

<siteMapNode url="Page3.aspx" title="Services" description="services" />

</siteMapNode>

</siteMap>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 5(B):-

Aim:- Create a web application to demonstrate use of Master Page with applying
Styles and Themes for page beautification.

1) Open Visual Studio → File → New → Website → ASP.NET Empty Web Site

2) Add new Item → Add Master Page

3) Add new Item → Add new Web form

4) Add new item → Add skin file

5) Add CSS file. Insert Themes attribute in Web page directive.

Source Code:-

Master page using WebForm.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"


AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication2.WebForm1" Theme="Skin1"%>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"


runat="server">

<h2>This is Webform</h2>

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

<asp:Label ID="Label2" runat="server"


Text="SHUBHAM"></asp:Label><br />

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

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

</asp:Content>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Site1.Master

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


CodeBehind="Site1.master.cs" Inherits="WebApplication2.Site1" %>

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

<link href="StyleSheet1.css" rel="stylesheet" type="text/css" />

<title></title>

<asp:ContentPlaceHolder ID="head" runat="server">

</asp:ContentPlaceHolder>

</head>

<body>

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

<h1>THIS IS MASTER PAGE</h1>

<h1>hiiiiiiiiiiiiiiiiiiiiii</h1>

<div>

<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

</asp:ContentPlaceHolder>

</div>

</form>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</body>

</html>

StyleSheet1.css

body

background-color:Yellow;

font-family:'Times New Roman'; font-size:larger;

Skin1.skin

<%--

Default skin template. The following skins are provided as examples only.

1. Named control skin. The SkinId should be uniquely defined because

duplicate SkinId's per control type are not allowed in the same theme.

<asp:GridView runat="server" SkinId="gridviewSkin" BackColor="White" >

<AlternatingRowStyle BackColor="Blue" />

</asp:GridView>

2. Default skin. The SkinId is not defined. Only one default

control skin per control type is allowed in the same theme.

<asp:Image runat="server" ImageUrl="~/images/image1.jpg" />

--%>

<asp:Label runat="server" ForeColor="Red" Font-Name="Verdana" />

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

<asp:Button runat="server" Borderstyle="Solid" Borderwidth="5px"/>

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 5(C1):-

Aim:- Create a web application to demonstrate various states of ASP.NET Pages.

Source Code:-

WebForm1.aspx

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


CodeBehind="WebForm1.aspx.cs" Inherits="prac5c.WebForm1" %>

<!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="Label"></asp:Label></br>

<asp:Button ID="Button1" runat="server" Text="Button"


onclick="Button1_Click" />

</div>

</form>

</body>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</html>

WebForm1.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace prac5c

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

int i = 0;

protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)

ViewState["Count"] = i;

protected void Button1_Click(object sender, EventArgs e)

i = (int)ViewState["Count"];

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Label1.Text = (++i).ToString();

ViewState["Count"] = i;

Output:-

Set breakpoint at Label1 then click F11 and then clock on Button in browser.

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 5(C2):-

Aim:- Query String Code.

Source Code:-

web form Query1.aspx

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


CodeBehind="query1.aspx.cs" Inherits="query.query1" %>

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

Name:-<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />

Userid:-<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />

<asp:Button ID="Button1" runat="server" Text="Button"


onclick="Button1_Click1" />

</div>

</form>

</body>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</html>

Query1.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace query

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click1(object sender, EventArgs e)

Response.Redirect("query2.aspx?Userid=" + TextBox1.Text + "&Name="


+ TextBox2.Text);

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Query2.aspx

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


CodeBehind="query2.aspx.cs" Inherits="query.query2" %>

<!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="form2" runat="server">

<div>

Name:-<asp:Label ID="Label1" runat="server"


Text="Label"></asp:Label><br />

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

</div>

</form>

</body>

</html>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Query2.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace query

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

protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)

Label1.Text = Request.QueryString["Userid"];

Label2.Text = Request.QueryString["Name"];

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Practical 5(C3):-

Aim:- Session.

Source Code:-

A] Open Visual Studio → File → New → Website → ASP.NET Empty Web Site.

B] Add new Item → Add new Web form

C] Add New WebForm1.aspx

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


CodeBehind="WebForm1.aspx.cs" Inherits="session.WebForm1" %>

<!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:ListBox ID="lstItems" runat="server"></asp:ListBox>

<asp:Button ID="Button1" runat="server" Text="Button"


onclick="Button1_Click" /><br />

<asp:Label ID="lblSession" runat="server"


Text="Label"></asp:Label><br />

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

</div>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

</form>

</body>

</html>

Web.config

<?xml version="1.0"?>

<configuration>

<system.web>

<compilation debug="true" targetFramework="4.0" />

</system.web>

</configuration>

<system.web>

<sessionState cookieless="UseCookies" cookieName="ASP.NET_SessionId"

regenerateExpiredSessionId="false" timeout="20" mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"
stateNetworkTimeout="10"

sqlConnectionString="data source=127.0.0.1;Integrated
Security=SSPI"

sqlCommandTimeout="30" allowCustomSqlDatabase="false"

customProvider=" " compressionEnabled="false"/>

</system.web>

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

WebForm1.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace session

public class Furniture

public string Name;

public string Description;

public decimal Cost;

public Furniture(string name, string description, decimal cost)

Name = name;

Description = description;

Cost = cost;

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

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

protected void Page_Load(object sender, EventArgs e)

if (!this.IsPostBack)

//Create Furniture objects.

Furniture piece1 = new Furniture("Econo Sofa", "Acme Inc", 77.99M);

Furniture piece2 = new Furniture("Pioneer Table", "Heritage Unit",


866.75M);

Furniture piece3 = new Furniture("Retro Cabinet", "Sixties LDT",


300.11M);

//ADD OBJECTS TO SESSION STATE

Session["Furniture1"] = piece1;

Session["Furniture2"] = piece2;

Session["Furniture3"] = piece3;

lstItems.Items.Add(piece1.Name);

lstItems.Items.Add(piece2.Name);

lstItems.Items.Add(piece3.Name);

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

//DISPLAY SOME BASIC INFO ABOUT THE SESSION.

//THIS IS USEFUL FOR TESTING CONFIGURATION SETTINGS.

lblSession.Text = "Session ID:" + Session.SessionID;

lblSession.Text += "<br/>Number of Objects:";

lblSession.Text += Session.Count.ToString();

lblSession.Text += "<br/>Mode:" + Session.Mode.ToString();

lblSession.Text += "<br/>Is Cookieless:";

lblSession.Text += Session.IsCookieless.ToString();

lblSession.Text += "<br/>Is New:";

lblSession.Text += Session.IsNewSession.ToString();

lblSession.Text += "<br/>Timeout(minutes):";

lblSession.Text += Session.Timeout.ToString();

protected void Button1_Click(object sender, EventArgs e)

if(lstItems.SelectedIndex == -1)

lblRecord.Text="No item Selected.";

else

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

//construct the right key name based on the index.

string key="Furniture"+(lstItems.SelectedIndex + 1).ToString();

//Retrive the furniture object from session state.

Furniture piece = (Furniture)Session[key];

//Display the information for this objects.

lblRecord.Text = "Name:" +piece.Name;

lblRecord.Text += "<br/>Manufacturer:";

lblRecord.Text += piece.Description;

lblRecord.Text += "<br/>Cost: "+piece.Cost.ToString("c");

Output:-

Advanced Web Programming Practicals


Name:- Sanket Harishchandra Dalvi AWP Practicals Std:- T.Y.B.Sc.IT
Roll No:- 715 Div:- A

Advanced Web Programming Practicals

You might also like