Download as pdf or txt
Download as pdf or txt
You are on page 1of 154

T.Y.B.Sc.

IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

1. Working with basic C# and ASP.NET

Practical 1A

Aim: Create an application that obtains four int values from the user and
displays the product.

using System; public


class Program
{
public static void Main()
{ int x, y, z, p;
Console.WriteLine("Enter nol:"); 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();
}
}

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

B. Create an application to demonstrate String Operation.

Default.aspx :

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


Inherits="WebApplication6._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:TextBox ID="TextBox1" runat="server" Text="string length:"></asp:TextBox>

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


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

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

<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="replace:"></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>

Default.aspx.cs

using System; using


System.Collections.Generic; using
System.Linq; using System.Web;
using System.Web.UI;
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

using System.Web.UI.WebControls;

namespace WebApplication6

public partial class _Default : 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(4, 3);

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


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

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

Label10.Text = "Replace:" + s.Replace("Ehtishaam", "Shaikh");

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

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


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

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

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

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

OUTPUT :

C . create an application to demonstrate following

operations

Practical 1C: i] Aim: Generate

Fibonacci series

using System;

public class Program


{
public static void Main()
{ int f1 = 0, f2 = 1, f3, n, co;
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Console.WriteLine("Enter the no"); n =


int.Parse(Console.ReadLine()); co = 3;
Console.WriteLine("Fibonaaci Series");
Console.WriteLine(f1 + "\t" + f2); while (co
<= n)
{
f3 = f1 + f2;
Console.WriteLine("\t" + f3); f1
= f2; f2 = f3;

co++;
}
Console.ReadLine();
}
}

Output:

Ii] Aim: Test for prime numbers


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

using System; public


class Program
{
public static void Main()
{
int num,c=0;
Console.WriteLine("enter a number");
num=int.Parse(Console.ReadLine()); for(int
i=1;i<=num;i++)
{
if(num % i==0) c++;
}
if(c==2)
{
Console.WriteLine(num+"is prime");
}
else
{
Console.WriteLine(num+"is not prime");
}
Console.ReadLine();

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Iii] Aim : Test for vowels

using System;

public class Program


{
public static void Main()
{ char[] v={'a','e','i','o','u'}; char
ch;
Console.WriteLine("enter");
ch=Convert.ToChar(Console.ReadLine().ToLower());
for(int i=0;i<5;i++)
{ if(ch==v[i])
{
Console.WriteLine(ch+"is vowel"); break;
} else
if(i==4)

{
Console.WriteLine(ch+"is not vowel");
}
}
Console.ReadLine();
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

}
}

Output:

iv] Aim : Use of foreach loop with arrays

using System;

public class Program


{
public static void Main()
{

int[] ch={1,2,3,4,5}; foreach(int c in ch)


{
Console.Write(c+" ");
}
Console.ReadLine();

}
}

Output:

V] Aim: Reverse a number and find sum of digits of a number


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

using System;

public class Program


{
public static void Main()
{
Console.WriteLine("Enter a No. to reverse"); int Number = int.Parse(Console.ReadLine()); int
Reverse = 0; while(Number>0)
{
int remainder = Number % 10;
Reverse = (Reverse * 10) + remainder;
Number = Number / 10;
}

Console.WriteLine("Reverse No. is {0}",Reverse);


Console.Write("Input a number: "); int n =
int.Parse(Console.ReadLine()); int sum = 0; while (n
!= 0) { sum += n % 10; n /= 10;
}
Console.WriteLine("Sum of the digits of the said integer: " + sum); Console.ReadLine();

}
}

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Practical 2 . Working with Object Oriented C# and ASP.NET a .

Create simple application to demonstrate use of following

concepts

i] Aim: to demonstrate function overloading

Code:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

using System;

namespace test1
{
class Program
{
public int Area(int a,int b)
{
return a* b;
}
public int Area(int a)
{
return a * a;
}
public double Area(double a)
{
return 3.14*a*a;
}
}
class Profram1
{

static void Main(string[] args)


{
Program p = new Program();
int res = p.Area(6,7); int squ =
p.Area(5); double circ =
p.Area(5.7);
Console.WriteLine("area of React=" + res + "\n");
Console.WriteLine("area of Square=" + squ + "\n");
Console.WriteLine("area of circle=" + circ + "\n");
Console.ReadLine();

}
}

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

ii] Aim: To demonstrate single inheritance (all types)

Code:

using System;

namespace single
{
class Teacher
{
public void Teach()
{
Console.WriteLine("tech");
}
}
class Student : Teacher
{
public void Learn()
{
Console.WriteLine("learn");
}
}

class Program
{
static void Main(string[] args)
{
Teacher T = new Teacher();
T.Teach();

Student S = new Student();


S.Learn();
S.Teach();
Console.ReadLine();
}
}
}

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

ii] Aim: to demonstrate Multi-level inheritance.(all types)

Code:

using System;

namespace multilevel
{
class Mode
{
public void mode()
{
Console.WriteLine("there are many modes of transport");
}
}

class vehicle :Mode


{
public void feature()
{

Console.WriteLine("they mainly help in travling");


}
}
class inheri:vehicle
{
public void noise()
{
Console.WriteLine("all vehicle make noise");
}
static void Main(string[] args)
{
inheri I = new inheri();
I.mode();
I.feature();
I.noise();
Console.ReadLine();
}
}
}

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

ii] Aim: To demonstrate hierarchical inheritance(all types)

Code:

using System;

namespace cal
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

{
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
{
int div(int c, int d);

}
class calulation: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 a, int b)
{
return result2 = a - b;

}
public int result3;
public int mul(int a, int b)
{
return result3 = a * b;
}
public int result4;
public int div(int a, int b)
{
return result4= a / b;
}
class test
{
static void Main(string[] args)
{
calulation C = new calulation();
C.add(3, 4);
C.div(4, 8);
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

C.sub(3, 2);
C.mul(4, 2);
Console.WriteLine("addtion"+C.result1);
Console.WriteLine("subtration" + C.result2);
Console.WriteLine("multiplication" + C.result3);
Console.WriteLine("divsion" + C.result4);
Console.ReadKey();
}
}
}

Output :

ii] Aim : To demonstrate hybrid inheritance (all types)

Code:

using System;
namespace cal
{
class program
{
static void Main(string[] args)
{
grandfather g = new grandfather(); g.truck(); dad d = new dad();
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

d.truck();
d.car(); son s =new
son(); s.truck();
s.bike();
Console.ReadLine();

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

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

iii] Aim: to demonstrate construction overloading

Code:

using System;

namespace cal
{
class BankAccount
{
private int cust_id,bal; private
string cust_name;
public BankAccount()
{
cust_id = 1000;
cust_name = "not yet specifed"; 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;
bal = obj.bal;
}
public void showdata()
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

{
Console.WriteLine("cust id={0},cust name={1},cust bal={2}", cust_id, cust_name, bal);

}
}
class program
{
public static void Main(string[] args)
{
BankAccount a = new BankAccount();
BankAccount b = new BankAccount(102,"ehtishaam",200);
BankAccount c = new BankAccount(b); a.showdata();
b.showdata();
c.showdata();
Console.ReadLine();

}
}

Output:

IV] Aim : to demonstrate interface

Code:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

using System;

namespace tra
{
public interface Itransaction
{
string retcode();
int amtfunction();

}
public class transaction : Itransaction
{
private string tcode; private int
amount;
public transaction()
{
tcode = "";
amount = 0;
}
public transaction(string c, int a)
{
tcode = c;
amount = a;
}
public int amtfunction()
{
return amount;
}

public string retcode()


{
return tcode;
}
}
public class test : transaction
{
public static void Main(string[] args)
{

transaction t1 = new transaction("samay",400);

transaction t2 = new transaction("ehtishaam",600);

Console.WriteLine("hello " + t1.retcode() + " your balance:" + t1.amtfunction());


Console.WriteLine("hello " + t2.retcode() + " your balance:" + t2.amtfunction());
}
}

}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

B. Create simple application to demonstrate use of following concepts .

i] Aim : to demonstrate use of delegates and events

Code:

using System;

namespace delegate1

{
class program
{
public delegate void print(int value); static void
Main(string[] args)
{
print printdel = printnumber;
printdel(10000); printdel(200);
printdel = printmoney;
printdel(15000); printdel(200);
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
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

ii]Aim : demonstrate use of exception handling

Code:

using System;
using System.Collections.Generic; using
System.Linq;

namespace delegate1

{
class program
{
static void Main(String [] args)
{
Console.WriteLine("enter name"); string
studentname = Console.ReadLine();
IList<String> studentList = FindALLStudenstFromDatabas(studentname);
Console.WriteLine("total {0}:{1}", studentname, studentList.Count()); Console.ReadKey();
}
private static IList<String> FindALLStudenstFromDatabas(String studentName)
{
IList<String> studentList = null; return
studentList;
}

}
}

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Part b : with try and catch(delegates)

Code:

using System;
using System.Collections.Generic; using
System.Linq;

namespace delegate1

{
class program
{
static void Main(String [] args)
{
try
{
Console.WriteLine("enter name"); string
studentname = Console.ReadLine();

IList<String> studentList = FindALLStudenstFromDatabas(studentname);


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

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


}
catch(Exception ex)
{
Console.WriteLine("no student data exist");
}
Console.ReadKey();
}
private static IList<String> FindALLStudenstFromDatabas(String studentName)
{
IList<String> studentList = null; return
studentList;
}
}
}

Output:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Practical 3 . Working with web forms and controls

a . Create a simple web page with various server controls to demonstrate


setting and use of their properties.(Example :
AutoPostBack)

WebForm1.aspx

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

<br />
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

<br />

<asp:Label ID="Label2" runat="server" text="Interest Amount"></asp:Label> <asp:TextBox


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

<br />
<br />

<asp:label ID="Label13" runat="server" Text="Years"></asp:label>

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

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


OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">

<asp:ListItem>1</asp:ListItem>

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

<asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem>
</asp:DropDownList>

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

</div>

</form>

<p>

&nbsp;</p>

</body>

</html>

WebForm1.aspx.cs

using System;
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

using System.Collections.Generic; using


System.Linq; using System.Web; using
System.Web.UI; using
System.Web.UI.WebControls;

namespace WebApplication1

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

protected void Page_Load(object sender, EventArgs e)

protected void TextBox1_TextChanged(object sender, EventArgs e)

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

double p = Convert.ToDouble(TextBox4.Text); double r =


Convert.ToDouble(TextBox2.Text); double t =
Convert.ToDouble(DropDownList1.SelectedValue);
TextBox3.Text = Convert.ToString(p * (1 + r * t));

protected void Button1_Click(object sender, EventArgs e)


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Output:

B . Demonstrate the use of Calendar control to perform following


operations .

I) Display message in a calendar .

II) Display Vacation in a calendar control .

III) Selected day in Calendar using style .

IV) Difference between two calendar dates .


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

WebForm1.aspx

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


Inherits="WebApplication2._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:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC"

BorderColor="#FFCC66" BorderWidth="1px" Font-Names="Verdana" Font-Size="8pt"

ForeColor="#663399" Height="200px" OnDayRender="Calendar1_DayRender"

Width="220px" DayNameFormat="Shortest" ShowGridLines="True">


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

<DayHeaderStyle Font-Bold="True" BackColor="#FFCC66" Height="1px" />

<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />

<OtherMonthDayStyle ForeColor="#CC9966" />

<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />

<SelectorStyle BackColor="#FFCC66" />

<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"

ForeColor="#FFFFCC" />

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

</asp:Calendar>

<br />

<br />

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

<br />

<br />

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

<br />

<br />

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

<br />

<br />

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

<br />

<br />

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

<br />

<br />

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

<br />

</div>

</form>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

</body> </html>

WebForm1.as.cx

using System; using


System.Collections.Generic; using
System.Linq; using System.Web; using
System.Web.UI; using
System.Web.UI.WebControls;

namespace WebApplication2

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

protected void Page_Load(object sender, EventArgs e)

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 lb1 = new Label(); lb1.Text = "<br> teachers
day<br>";
e.Cell.Controls.Add(lb1);
Image g1 = new Image();
g1.ImageUrl = "263646.jpg";
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

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

protected void Button1_Click(object sender, EventArgs e)

Calendar1.Caption = "EHTISHAAM";

Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday;

Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth;

Calendar1.TitleFormat = TitleFormat.Month;

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

Label2.Text = "ganpati vacation starts: 9-10-2021";

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

Label3.Text = "days remaining for vacation " + d.Days.ToString();

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


Label4.Text = "days remaining for new year " + d1.Days.ToString(); if
(Calendar1.SelectedDate.ToShortDateString() == "9-10-2021")
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Label5.Text = "<b>Ganpati Festival start</b>";

if (Calendar1.SelectedDate.ToShortDateString() == "9-18-2021")

Label5.Text = "<b>Ganpati Festival end</b>";

Output:

PRACTICAL 4 : WORKING WITH FORM CONTROLS


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

A ) Create a Registration form to demonstrate use of various validation


controls .

Webform2.aspx

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


Inherits="WebApplication10.WebForm2" %>

<!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 class="style1">
Name
</td>
<td class="style2">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="Enter Name"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ErrorMessage="Enter Only Character" ControlToValidate="TextBox1"
ValidationExpression="[a-zA-Z]+"></asp:RegularExpressionValidator>
</td>
</tr>

<tr>
<td class="style1">
Roll no
</td>
<td class="style2">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="Enter no"
ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
</td>
</tr>

<tr>
<td class="style1">
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

Age
</td>
<td class="style2">
<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"
ControlToValidate="TextBox3"
MaximumValue="25" MinimumValue="18"></asp:RangeValidator>
</td>
</tr>

<tr>
<td class="style1">
Contact
</td>
<td class="style2">
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ErrorMessage="Enter Contact"
ControlToValidate="TextBox4"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ErrorMessage="CustomValidator" ControlToValidate="TextBox4"
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
</td>
</tr>

<tr>
<td class="style1">
Email
</td>
<td class="style2">
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ErrorMessage="Enter Email"
ControlToValidate="TextBox5"></asp:RequiredFieldValidator>
<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>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

<td class="style1">
Password
</td>
<td class="style2">
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ErrorMessage="Enter Password"
ControlToValidate="TextBox6"></asp:RequiredFieldValidator>

</td>
</tr>

<tr>
<td class="style1">
Re-Type Password
</td>
<td class="style2">
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ErrorMessage="Enter Re-Type Password"
ControlToValidate="TextBox7"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="Enter Correct Password" ControlToCompare="TextBox6"
ControlToValidate="TextBox7"></asp:CompareValidator>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

</td>
</tr>

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

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

</tr>

</table>
</div>
</form>
</body>
</html>

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

B) Create a Web Form to demonstrate use of Adrotator Control .

XML FILE : RIGHT CLICK ON PROJECT -> ADD -> NEW ITEM
-> DATA -> XML FILE

--> WebForm1.aspx

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


Inherits="WebApplication5._Default" %>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

<!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:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/XMLFile1.xml">
</asp:XmlDataSource>
</div>
</form>
</body>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: OM GUPTA

Roll No: 728

</html>

XMLFILE1.xml

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

<Advertisements>

<Ad>

<ImageUrl1>abc.jpg</ImageUrl1>

<NavigateUrl>https://www.youtube.com</NavigateUrl>

<AlternateText> this
is an image
</AlternateText>

<Impressions>1</Impressions>

<Keyword>game</Keyword>

</Ad>

<Ad>

<ImageUrl>xyz.jpg</ImageUrl>

<NavigateUrl>https://www.google.com</NavigateUrl>

<AlternateText>this is an image</AlternateText>

<Impressions>1</Impressions>

<keyword>games</keyword>

</Ad>

<Ad>

<ImageUrl>637668.jpg</ImageUrl>

<NavigateUrl>https://www.epicgames.com/store/en-US/</NavigateUrl>

<AlternateText>this is an image</AlternateText>

<Impressions>2</Impressions>

<keyword>games</keyword>

</Ad>

</Advertisements>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


C) Create Web Form to demonstrate use of User Controls.

RIGHT CLICK ON PROJECT -> ADD -> NEW ITEM -> WEB -
> WEB FORM USER CONTROL

DemoUserControl.aspx

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


CodeBehind="DemoUserControl.aspx.cs" Inherits="WebApplication9.DemoUserControl" %>
<%@ 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" />
<uc1:Student ID="Student1" runat="server" />
<uc1:Student ID="clr" runat="server" />
<uc1:Student ID="abc" runat="server" />
<uc1:Student ID="xyz" runat="server" />
</div>
</form>
</body>
</html>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

WebUserControl1.ascx

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


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

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


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />

WebUserControl1.ascx.cs

using System.Web.UI; using


System.Web.UI.WebControls;

namespace WebApplication9
{
public partial class WebUserControl1 : System.Web.UI.UserControl
{

protected void Page_Load(object sender, EventArgs e)


{

protected void Button1_Click(object sender, EventArgs e)


{
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


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

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

PRACTICAL 5 : WORKING WITH NAVIGATION , BEAUTIFICATION ,


AND MASTER PAGE .

A) Create Web Form to demonstrate use of website navigation controls and


site map .

WebForm1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication8.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">
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">

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


<Nodes>
<asp:TreeNode NavigateUrl="~/Page1.aspx" Text="Home" Value="Home">
<asp:TreeNode NavigateUrl="~/Page2.aspx" Text="About" Value="About">
<asp:TreeNode NavigateUrl="~/Calendar.aspx" Text="Calendar" Value="Calendar">
</asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode NavigateUrl="~/Page3.aspx" Text="Contact" Value="Contact">
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>

<asp:Menu ID="Menu1" runat="server">


<Items>
<asp:MenuItem NavigateUrl="~/Page1.aspx" Text="Home" Value="Home">
<asp:MenuItem NavigateUrl="~/Page2.aspx" Text="about" Value="about">
<asp:MenuItem NavigateUrl="~/Calendar.aspx" Text="Calendar" Value="Calendar">
</asp:MenuItem>
</asp:MenuItem>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<asp:MenuItem NavigateUrl="~/Page3.aspx" Text="contact" Value="contact">
</asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>

</form>
</body>
</html>

Web.sitemap
<?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="Calendar.aspx" title="calendar" description="calendar" />
</siteMapNode>
<siteMapNode url="Page3.aspx" title="contact" description="contact" />
</siteMapNode>
</siteMap>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Page1.aspx

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


Inherits="WebApplication8.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>
<h1>HOME</h1>
</div>
</form>
</body>
</html>

Page2.aspx

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


Inherits="WebApplication8.Page2" %>

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


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>ABOUT</h1>
</div>
</form>
</body>
</html>

Page3.aspx

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


Inherits="WebApplication8.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">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>CONTACT</h1>
</div>
</form>
</body>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


</html>

Calendar.aspx

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


Inherits="WebApplication8.Calendar" %>

<!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>
<h1>CALENDAR</h1>
</div>
</form>
</body>
</html>

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

B) Create Web application to demonstrate the use of Master


Page with applying Styles and Themes

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.
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

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


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

STYLESHEET1.CSS

body
{
background-color:yellow; font-family:'Times New Roman'; font-size:larger;
}

WEBFORM1.ASPX
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

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


AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication14.WebForm1" Theme="Skin1"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2> this is web form</h2>
<asp:Label ID="Label1" runat="server" Text="ehtishaam"></asp:Label><br />
<asp:Label ID="Label2" runat="server" Text="aamir"></asp:Label><br />
<asp:Label ID="Label3" runat="server" Text="faizan"></asp:Label><br />
<asp:Button ID="Button1" runat="server" Text="Submit" /> </asp:Content>

SITE1.MASTER
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"
Inherits="WebApplication14.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>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<form id="form1" runat="server">
<div>
<h1> Hi this is master page</h1>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

</asp:ContentPlaceHolder>
<h3>
fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooter</ h3>
</div>
</form>
</body>
</html>

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


C) Create a Web application to demonstrate various states of ASP.NET
Pages .

C1) View State

Default.aspx

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


Inherits="WebApplication11._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:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

</html>

Default.aspx.cs

using System; using


System.Collections.Generic; using
System.Linq; using System.Web; using
System.Web.UI; using
System.Web.UI.WebControls;

namespace WebApplication11
{
public partial class _Default : 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"];
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


Label1.Text = (++i).ToString();
ViewState["Count"] = i;
}
}
}

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

C2) Query String


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Query1.aspx

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


Inherits="WebApplication12._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>
User ID <asp:Label ID="Label1" runat="server" ></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
Name <asp:Label ID="Label2" runat="server" ></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="SUBMIT" OnClick="Button_Click" />
</div>
</form>
</body>
</html>

Query2.aspx

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


Inherits="WebApplication12.WebForm1" %>

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


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
UserID <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
Name <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br />
</div>
</form>
</body>
</html>

Query1.aspx.cs

using System; using System.Collections.Generic; using System.Linq;


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

using System.Web; using


System.Web.UI; using
System.Web.UI.WebControls;

namespace WebApplication12
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button_Click(object sender, EventArgs e)


{
Response.Redirect("Query2.aspx?UserID= " + TextBox1.Text + "&Name=" +
TextBox2.Text);
}
}
}

Query2.aspx.cs

using System; using System.Collections.Generic; using System.Linq;


using System.Web;
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

using System.Web.UI; using


System.Web.UI.WebControls;

namespace WebApplication12
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ if
(!IsPostBack)
{
Label1.Text = Request.QueryString["UserID"];
Label2.Text = Request.QueryString["Name"];
}
}
}
}

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

C3) COOKIE

Web.Config

<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


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

</configuration>

Cookies.aspx

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


Inherits="WebApplication13._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>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

</head>
<body>
<form id="form1" runat="server">
<div>
Name<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>

Cookie.aspx.cs

using System; using


System.Collections.Generic; using
System.Linq; using System.Web; using
System.Web.UI; using
System.Web.UI.WebControls;

namespace WebApplication13
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

HttpCookie cookie = Request.Cookies["Preferences"]; if


(cookie == null)
{
Label1.Text = "<b>Unknown Customer</b>";
}
else
{
Label1.Text = "<b>Cookie Found.</b><br /><br />";
Label1.Text += "Welcome, " + cookie["Name"];
}
}

protected void Button1_Click(object sender, EventArgs e)


{
HttpCookie cookie = Request.Cookies["Preferences"]; if
(cookie == null)
{
cookie = new HttpCookie("Preferences");
}
cookie["Name"] = txtName.Text; cookie.Expires
= DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
Label1.Text = "<b>Cookie Created.</b><br /><br />";
Label1.Text += "New Customer: " + cookie["Name"];
}
}
}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

OUTPUT :

C4) SESSION

Web.Config

<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

-->

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />

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

</configuration>

Session.aspx

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


Inherits="WebApplication13.Session" %>

<!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">
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<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" />
<asp:Label ID="lblSession" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="lblRecord" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>

Session.aspx.cs

using System; using System.Collections.Generic; using System.Linq; using System.Web; using


System.Web.UI; using System.Web.UI.WebControls;

namespace WebApplication13
{
public class Furniture
{
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

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 Session : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
// create furniture objects.
Furniture piece1 = new Furniture("Econo Sofa", "Acme Inc.", 74.99M);
Furniture piece2 = new Furniture("Pioneer Table", "Heritage Unit", 866.75M);
Furniture piece3 = new Furniture("Retro Cabinet", "Sixties Ltd.", 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);
}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

// display some basic information 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 {
//construct the right key name based on the index .
string key = "Furniture" + (lstItems.SelectedIndex + 1).ToString();
//retrieve the furniture object from session state.
Furniture piece = (Furniture)Session[key]; //display
the information for this object.
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

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


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

}
}
}
}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

OUTPUT :

PRACTICAL 6

AIM : Create a Web application bind data in a multiline textbox by querying


in another textbox.

WEBFORM1.ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication15.WebForm1" %>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<!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" Height="50px"
TextMode="MultiLine" Width="205px"></asp:TextBox>

<asp:Button ID="Button1" runat="server" Height="47px" OnClick="Button1_Click"


Text="Button" />

<asp:ListBox ID="ListBox1" runat="server" Height="130px" style="margin-right: 24px; margin-


top: 32px" Width="177px"></asp:ListBox>
</div>
</form>
</body>
</html>

WEB.CONFIG
<connectionStrings>
<add name="customer" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename='c:\users\hp\documents\visual studio
2010\Projects\WebApplication15\WebApplication15\App_Data\Database1.mdf';Integ rated
Security=True;User Instance=True"/>
</connectionStrings>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


DATABASE

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Practical 6B

Aim: create a web application to display records by using database


Create a webpage with one button and one label
Write the database related code in c#

DEFAULT.ASPX

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


CodeBehind="Default.aspx.cs" Inherits="WebApplication16._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">
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<div>
<p>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</p>
<p>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Button" />
</p>
</div>
</form>
</body>
</html>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

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.SqlClient;

namespace WebApplication16
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

protected void Button1_Click(object sender, EventArgs e)


{
string connStr =
System.Configuration.ConfigurationManager.ConnectionStrings["stud"].Connecti onString;
SqlConnection con = new SqlConnection(connStr);
con.Open();

SqlCommand cmd = new SqlCommand("Select name,age from stud", con);


SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Label1.Text += reader["name"].ToString() + " " + reader["age"].ToString() +
"<br>";
}

reader.Close();
con.Close();

}
}
}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

WEB.CONFIG

<connectionStrings>
<add name="stud" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename='c:\users\hp\documents\visual studio
2010\Projects\WebApplication16\WebApplication16\App_Data\Database1.mdf ';Integrated
Security=True;User Instance=True" />
<add name="ConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Int egrated
Security=True;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>

DATABASE :

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Practical 6c
Aim : Dataset
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

WEBFORM1.ASPX

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


CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication16.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:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
id:
<asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' />
<br />
name:
<asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

<br />
age:
<asp:Label ID="ageLabel" runat="server" Text='<%# Eval("age") %>'
/>
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [stud]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>

DATALIST CONNECTION :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

OUTPUT :

Practical 7
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Aim : Only Data Which Is Selected .

DEFAULT.ASPX
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication17._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:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>

<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</div>
</form>
</body>
</html>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

DEFAULT.ASPX.CS

using System; using System.Collections.Generic; using


System.Linq; using System.Web;
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

using System.Web.UI; using


System.Web.UI.WebControls; using
System.Configuration; using
System.Data.SqlClient;

namespace WebApplication17
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
string connStr =
ConfigurationManager.ConnectionStrings["Ehtishaam"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
con.Open();
SqlCommand cmd = new SqlCommand("Select City from Ehtishaam", con);
SqlDataReader reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataTextField = "City";
DropDownList1.DataBind(); reader.Close();
con.Close();
}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


}

protected void Button1_Click(object sender, EventArgs e)


{
Label1.Text = "The value you have selected" + DropDownList1.SelectedValue;
}
}
}

WEB.CONFIG

<connectionStrings>
<add name="Ehtishaam" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename='c:\users\hp\documents\visual studio
2010\Projects\WebApplication17\WebApplication17\App_Data\Database1.mdf
';Integrated Security=True;User Instance=True"/>
</connectionStrings>

DATABASE
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

OUTPUT :

Practical 7b
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


Aim : Select Data Value

DEFAULT.ASPX

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


CodeBehind="Default.aspx.cs" Inherits="WebApplication18._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:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>

<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</div>
</form>
</body>
</html>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

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.Configuration; using
System.Data.SqlClient;

namespace WebApplication18
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
string connStr =
ConfigurationManager.ConnectionStrings["rcb"].ConnectionString;
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

SqlConnection con = new SqlConnection(connStr);


con.Open();
SqlCommand cmd = new SqlCommand("Select distinct Name,PhoneNo from rcb",
con);
SqlDataReader reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "PhoneNo";
DropDownList1.DataBind(); reader.Close();
con.Close();
}
}

protected void Button1_Click(object sender, EventArgs e)


{
Label1.Text = "your number is:" + "" + DropDownList1.SelectedValue;
}
}
}

WEB.CONFIG

<connectionStrings> <add name="rcb" connectionString="Data


Source=.\SQLEXPRESS;AttachDbFilename='c:\users\hp\documents\visual studio
2010\Projects\WebApplication18\WebApplication18\App_Data\Database1.mdf
';Integrated Security=True;User Instance=True"/>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


</connectionStrings>

DATABASE

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Practical 7C Aim:
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

DEFAULT.ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="WebApplication19._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>
<h1>Customer Details</h1>
<table style="width: 100%;">
<tr>
<td class="style1">
Cust ID
</td>
<td class="style2">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

<tr>
<td class="style1">
Name
</td>
<td class="style2">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>

<tr>
<td class="style1">
City
</td>
<td class="style2">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>

<tr>
<td class="style1">
PhoneNo
</td>
<td class="style2">
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
</tr>

<tr>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<td>
<asp:Button ID="Button1" runat="server" Text="Insert" onclick="Button1_Click1"
style="height: 26px" />
</td>
<td>
<asp:Button ID="Button2" runat="server" Text="Delete" onclick="Button2_Click2" />
</td>
</tr>

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

</table>
</div>
</form>
</body>
</html>

DEFAULT.ASPX.CS

using System; using System.Collections.Generic;


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

using System.Linq; using System.Web;


using System.Web.UI; using
System.Web.UI.WebControls; using
System.Configuration; using
System.Data.SqlClient;

namespace WebApplication19
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click1(object sender, EventArgs e)


{
string constr =
ConfigurationManager.ConnectionStrings["customer"].ConnectionString;
SqlConnection conn = new SqlConnection(constr);
string insertq = "insert into customer values(@CustId,@Name,@City,@PhoneNo)";
SqlCommand cmd = new SqlCommand(insertq, conn);

cmd.Parameters.AddWithValue("@CustId", TextBox1.Text);
cmd.Parameters.AddWithValue("@Name", TextBox2.Text);
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

cmd.Parameters.AddWithValue("@City", TextBox3.Text);
cmd.Parameters.AddWithValue("@PhoneNo", TextBox4.Text);
conn.Open();
cmd.ExecuteNonQuery();

Label1.Text = "Record Added Successfully";


conn.Close();
}

protected void Button2_Click2(object sender, EventArgs e)


{
string constr =
ConfigurationManager.ConnectionStrings["customer"].ConnectionString;
SqlConnection conn = new SqlConnection(constr); string insertq = "delete
from customer where Name=@Name"; SqlCommand cmd = new
SqlCommand(insertq, conn); cmd.Parameters.AddWithValue("@Name",
TextBox2.Text);

conn.Open();
cmd.ExecuteNonQuery();

Label1.Text = "Record Deleted Successfully";


conn.Close();
}
}
}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

WEB.CONFIG

<connectionStrings>
<add name="customer" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename='c:\users\hp\documents\visual studio
2010\Projects\WebApplication19\WebApplication19\App_Data\Database1.mdf ';Integrated
Security=True;User Instance=True" />
<add name="ConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Int egrated
Security=True;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>

DATABASE

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Practical 8A
Aim: Create a web application to demonstrate data binding using details
view and form view control
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

WEBFORM 2.ASPX

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


CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication19.WebForm2" %>

<!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:DetailsView ID="DetailsView1" runat="server" Height="50px"
Width="125px"
AutoGenerateRows="False" AllowPaging="true" DataSourceID="SqlDataSource1"
EnableModelValidation="True">
<Fields>
<asp:BoundField DataField="CustId" HeaderText="CustId"
SortExpression="CustId" />
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

<asp:BoundField DataField="Name" HeaderText="Name"


SortExpression="Name" />
<asp:BoundField DataField="City" HeaderText="City"
SortExpression="City" />
<asp:BoundField DataField="PhoneNo" HeaderText="PhoneNo"
SortExpression="PhoneNo" />
</Fields>
</asp:DetailsView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"


ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [customer]"></asp:SqlDataSource>

<asp:FormView ID="FormView1" runat="server" AllowPaging="True"


DataSourceID="SqlDataSource1" EnableModelValidation="True">
<EditItemTemplate>
CustId:
<asp:TextBox ID="CustIdTextBox" runat="server" Text='<%# Bind("CustId")
%>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'
/>
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

PhoneNo:
<asp:TextBox ID="PhoneNoTextBox" runat="server" Text='<%#
Bind("PhoneNo") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True"
CommandName="Update" Text="Update" />
&nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate> <InsertItemTemplate>
CustId:
<asp:TextBox ID="CustIdTextBox" runat="server" Text='<%# Bind("CustId")
%>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'
/>
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
PhoneNo:
<asp:TextBox ID="PhoneNoTextBox" runat="server" Text='<%#
Bind("PhoneNo") %>' />
<br />
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

<asp:LinkButton ID="InsertButton" runat="server"


CausesValidation="True"
CommandName="Insert" Text="Insert" />
&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
CustId:
<asp:Label ID="CustIdLabel" runat="server" Text='<%# Bind("CustId") %>' />
<br />
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
<br />
City:
<asp:Label ID="CityLabel" runat="server" Text='<%# Bind("City") %>'
/>
<br />
PhoneNo:
<asp:Label ID="PhoneNoLabel" runat="server" Text='<%# Bind("PhoneNo") %>'
/>
<br />

</ItemTemplate>
</asp:FormView>
</div>
</form>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


</body>
</html>

NOW TO SELECT DATABASE

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Practical 8B Aim: Create a web application to display using disconnected


data access and data binding using grid view

WEBFORM 1.ASPX

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


CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication19.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>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
onselectedindexchanged="GridView1_SelectedIndexChanged1">

</asp:GridView>
</div>
</form>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

</body>
</html>

WEBFORM 1.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.Configuration; using
System.Data.SqlClient; using
System.Web.Configuration; using
System.Data;

namespace WebApplication19
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString =
WebConfigurationManager.ConnectionStrings["customer"].ConnectionString;
string selectSQL = "SELECT CustId, Name, City, PhoneNo FROM customer";
SqlConnection con = new SqlConnection(connectionString);
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

SqlCommand cmd = new SqlCommand(selectSQL, con);


SqlDataAdapter adapter = new SqlDataAdapter(cmd);
// Fill the DataSet.
DataSet ds = new DataSet();
adapter.Fill(ds, "customer"); //
Perform the binding.
GridView1.DataSource = ds;
GridView1.DataBind();
}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs


e)
{
}

protected void GridView1_SelectedIndexChanged1(object sender, EventArgs


e)
{

}
}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

WEB.CONFIG

<connectionStrings>
<add name="customer" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename='c:\users\hp\documents\visual studio
2010\Projects\WebApplication19\WebApplication19\App_Data\Database1.mdf ';Integrated
Security=True;User Instance=True" />
<add name="ConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Int egrated
Security=True;User Instance=True" providerName="System.Data.SqlClient" />
</connectionStrings>

DATABASE

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Practical 9A
Aim: Create a web application to demonstrate Grid View paging and
creating own table format using grid view.

WEBFORM 1.ASPX

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


CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication20.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">
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
AllowPaging="True" PageSize="2"
EnableModelValidation="True"
OnPageIndexChanging="GridView1_PageIndexChanging">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" />
<asp:BoundField DataField="name" HeaderText="name" />
<asp:BoundField DataField="url" HeaderText="url" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>

WEBFORM 1.ASPX.CS

using System; using System.Collections.Generic;


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

using System.Linq; using System.Web;


using System.Web.UI; using
System.Web.UI.WebControls; using
System.Data.SqlClient; using
System.Web.Configuration; using
System.Data;

namespace WebApplication20
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}

public void BindData()


{
string connectionString =
WebConfigurationManager.ConnectionStrings["url"].ConnectionString; string
selectSQL = "SELECT id, name, url FROM url";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(selectSQL, con);
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


SqlDataAdapter adapter = new SqlDataAdapter(cmd);
// Fill the Dataset.
DataSet ds = new DataSet();
adapter.Fill(ds, "info");
// Perform the binding.
GridView1.DataSource = ds;
GridView1.DataBind();
}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs


e)
{
GridView1.PageIndex = e.NewPageIndex;
this.BindData();
}

}
}

WEB.CONFIG

<connectionStrings>
<add name="url" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename='c:\users\hp\documents\visual studio
2010\Projects\WebApplication20\WebApplication20\App_Data\Database1.md f';Integrated
Security=True;User Instance=True"/>
</connectionStrings>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


EDIT COLUMNS

DATABASE
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

OUTPUT :

Practical 9B
Aim: Create a web application to demonstration use of gird view control
template and grid view hyperlink
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

WEBFORM 2.ASPX
%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication20.WebForm2" %>

<!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:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
EnableModelValidation="True"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" />
<asp:HyperLinkField DataNavigateUrlFields="url" DataTextField="Name"
HeaderText="User Profile" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

WEBFORM 2.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.SqlClient; using
System.Web.Configuration; using
System.Data;

namespace WebApplication20
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

string connectionString =
WebConfigurationManager.ConnectionStrings["url"].ConnectionString; string
selectSQL = "SELECT id, name, url FROM url";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(selectSQL, con); SqlDataAdapter
adapter = new SqlDataAdapter(cmd);
// Fill the Dataset.
DataSet ds = new DataSet();
adapter.Fill(ds, "info");
// Perform the binding.
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)


{

}
}
}

WEB.CONFIG

<connectionStrings> <add name="url" connectionString="Data


Source=.\SQLEXPRESS;AttachDbFilename='c:\users\hp\documents\visual studio
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


2010\Projects\WebApplication20\WebApplication20\App_Data\Database1.md f';Integrated
Security=True;User Instance=True"/>
</connectionStrings>

TO CREATE COLUMN AND HYPERLINK

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Practical 10A Aim: Creating a web application to demonstrate reading and


writing operation with XML

DEFAULT.ASPX

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


CodeBehind="Default.aspx.cs" Inherits="WebApplication21._Default" %>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

<!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 />
<br />
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
<br />
<br />
<asp:ListBox ID="ListBox1" runat="server" Height="40px" Width="100px"

onselectedindexchanged="ListBox1_SelectedIndexChanged"></asp:ListBox>
<br />
<br />
<asp:Button ID="Button2" runat="server" Text="Button"
onclick="Button2_Click" />
</div>
</form>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


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

namespace WebApplication21
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
XmlTextWriter Wr = new
XmlTextWriter("C:\\Users\\HP\\Music\\AWPPRACTICAL", null);
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Wr.WriteStartDocument();
Wr.WriteStartElement("Details", "top");
Wr.WriteElementString("ID", "1");
Wr.WriteElementString("FirstName", "ehtishaam");
Wr.WriteElementString("LastName", "shaikh"); Wr.WriteEndElement();

Wr.Close();
Label1.Text = "Datawrite successfully";
}

protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)


{

protected void Button2_Click(object sender, EventArgs e)


{
String xn = "C:\\Users\\HP\\Music\\AWPPRACTICAL"; XmlReader xr
= XmlReader.Create(xn);
while (xr.Read())
{
switch (xr.NodeType)
{
case XmlNodeType.Element:
ListBox1.Items.Add("<" + xr.Name + ">");
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


break;
case XmlNodeType.Text: ListBox1.Items.Add(xr.Value);
break;
case XmlNodeType.EndElement:
ListBox1.Items.Add("</" + xr.Name + ">");
break;
}
}
}
}
}

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

Practical 10B

AIM : Create a Web Application to demonstrate From Security and


Windows Security with Proper Authentication and
Authorization Properties

Default.aspx

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


CodeBehind="Default.aspx.cs" Inherits="WebApplication22._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>
ENTER USERNAME : <asp:TextBox ID="TextBox1" runat="server"
ontextchanged="TextBox1_TextChanged"></asp:TextBox><br /> ENTER PASSWORD :
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />

<asp:Button ID="Button1" runat="server" Text="Login" onclick="Button1_Click" /><br


/>
<asp:CheckBox ID="CheckBox1" runat="server" /> if it is not public computer<br />
</div>
</form>
</body>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


</html>

Default.aspx.cs

using System; using


System.Collections.Generic; using
System.Linq; using System.Web; using
System.Web.Security; using
System.Web.UI; using
System.Web.UI.WebControls;

namespace WebApplication22
{
public partial class _Default : System.Web.UI.Page
{
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

protected void Page_Load(object sender, EventArgs e)


{

protected void TextBox1_TextChanged(object sender, EventArgs e)


{

protected bool authenticate(String uname, String pass)


{
if (uname == "Samay")
{
if (pass == "samay123")
return true;
}

if (uname == "Ehtishaam")
{
if (pass == "Ehtishaam123")
return true;
}

if (uname == "Nitesh")
{
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

if (pass == "nitesh123")
return true;
}

return false;
}

protected void Button1_Click(object sender, EventArgs e)


{
if(authenticate(TextBox1.Text, TextBox2.Text))
{
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text,
CheckBox1.Checked);
Session["Username"] = TextBox1.Text;
Response.Redirect("Default2.aspx");
}
else
{
Response.Write("Invalid user name or password");
}
}
}
}
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


Default2.aspx

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


CodeBehind="Default2.aspx.cs" Inherits="WebApplication22.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>
<form id="form1" runat="server">
<div>
Welcome to the programming world of dot net. <asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label>
</div>
</form>
</body>
</html>

Default2.aspx.cs

using System; using


System.Collections.Generic;
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

using System.Linq; using System.Web;


using System.Web.UI; using
System.Web.UI.WebControls;

namespace WebApplication22
{
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Session["Username"]!=null)
{
//Response.Write(Session["Username"].ToString()); Label1.Text =
Session["Username"].ToString();
}
}
}
}

Web.Config

<authentication mode="Forms">
<forms loginUrl="Default.aspx"/>
</authentication>
<authorization>
<deny users="?"/> </authorization>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


OUTPUT :

Practical Aim:

Multiview Code:

Default.aspx :

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


CodeBehind="Default.aspx.cs" Inherits="WebApplication7._Default" %>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


<!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:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="0">Calendar</asp:ListItem>
<asp:ListItem Value="1">Color</asp:ListItem>

</asp:DropDownList>

<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="1">


<asp:View ID="view1" runat="server">
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</asp:View>

<asp:View ID="View2" runat="server">


<asp:Label ID="Label1" runat="server" Text="Color format"></asp:Label>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">

<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Green</asp:ListItem>
</asp:RadioButtonList>
</asp:View>
</asp:MultiView>
</div>
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888


</form>
</body>
</html>

Default.aspx.cs :
using System; using System.Collections.Generic; using
System.Linq; using System.Web; using System.Web.UI;
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

using System.Web.UI.WebControls;

namespace WebApplication7
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{
MultiView1.ActiveViewIndex =
Convert.ToInt32(DropDownList1.SelectedValue);
}
}
}

OUTPUT :
T.Y.B.Sc.IT ADVANCED WEB PROGRAMMING Name: Md. Ehtishaam Shaikh

Roll No: 888

You might also like