Nothing Special   »   [go: up one dir, main page]

Sanket Java Practical

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

T.Y.BSc.

IT
SEMESTER-V
ADVANCE JAVA
PROGRAMMING
PRACTICAL
2021-2022

following operations.
INDEX
Practical
Details
No

1 Working with basic C# and ASP .NET

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

b Create an application to demonstrate string operations.

Create an application that receives the (Student Id, Student Name, Course
Name, Date of Birth) information from a set of students. The application
c
should also display the information of all the students once the data
entered.

Create an application to demonstrate following operations


i. Generate Fibonacci series.
ii. Test for prime numbers.
d
iii. Test for vowels.
iv. Use of foreach loop with arrays
v. Reverse a number and find sum of digits of a number.

2 Working with Object Oriented C# and ASP .NET

Create simple application to perform following operations


i. Finding factorial Value
a ii. Money Conversion
iii. Quadratic Equation
iv. Temperature Conversion

Create simple application to demonstrate use of following concepts


i. Function Overloading
b ii. Inheritance (all types)
iii. Constructor overloading
iv. Interfaces
Create simple application to demonstrate use of following concepts
c i. Using Delegates and events
ii. Exception handling

3 Working with Web Forms and Controls

Create a simple web page with various sever controls to demonstrate


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

Demonstrate the use of Calendar control to perform following operations.


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

Demonstrate the use of Treeview control perform following operations.


c a) Treeview control and datalist
b) Treeview operations

4 Working with Form Controls

Create a Registration form to demonstrate use of various Validation


a
controls.

b Create Web Form to demonstrate use of Adrotator Control.

c Create Web Form to demonstrate use User Controls.

5 Working with Navigation, Beautification and Master page.

Create Web Form to demonstrate use of Website Navigation controls and


a
Site Map.

Create a web application to demonstrate use of Master Page with applying


b
Styles and Themes for page beautification.

c Create a web application to demonstrate various states of ASP.NET Pages.

6 Working with Database

a Create a web application bind data in a multiline textbox by querying in


another textbox.

b Create a web application to display records by using database.

c Demonstrate the use of Datalist link control.

7 Working with Database

a Create a web application to display Databinding using dropdownlist control.

Create a web application for to display the phone no of an author using


b
database.

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

8 Working with data controls

Create a web application to demonstrate various uses and properties of


a
SqlDataSource.

Create a web application to demonstrate data binding using DetailsView


b
and FormView Control.

Create a web application to display Using Disconnected Data Access and


c
Databinding using GridView.

9 Working with GridView control

Create a web application to demonstrate use of GridView control template


a
and GridView hyperlink.

Create a web application to demonstrate use of GridView button column


b
and GridView events.

Create a web application to demonstrate GridView paging and Creating own


c
table format using GridView.

CERTIFICATE
CLASS: - TYBSCIT YEAR: -2021-2022
This is to certify that the work entered in this journal is the
work of

Shri/kumari: - KHARAT SANKET SUNIL


OF TYBSCIT DIVISION: -A ROLL NO.7
Uni. Exam NO _______________has satisfactorily completed the
required number
Of practical and worked for the 1st term/2nd term/3rd term
both the term of this
year 2020-2021 in the college laboratory as laid down by the
university

SAMEERA MAAM __________________ SAMEERA MAAM


HEAD OF Department External examiner INTERNAL
Teacher

Practical no.1: Working with basic C# and ASP .NET.


Program 1(a): Create an application that obtain four int values from
the user and display the product.
Ans:- using System; using System.Collections.Generic; using System.Linq;
using System.Web; using System.Web.UI; using
System.Web.UI.WebControls;

namespace Practical1_a_
{ public partial class WebForm1 :
System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = " ";
TextBox2.Text = " ";
TextBox3.Text = " ";
TextBox4.Text = " ";
Label5.Text = "Answer Is:- ";
}
protected void Button1_Click(object sender, EventArgs e)
{
Label5.Text +=
Convert.ToInt16(TextBox1.Text)*Convert.ToInt16(TextBox2.Text)*Con
vert.ToInt16(Text Box3.Text)*Convert.ToInt16(TextBox4.Text);
}
}
}

Output:-

Program 1(b): Create an application to demonstrate


string operations.
Ans:- using System; using System.Collections.Generic;
using System.Linq; using System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;

namespace String_Operation
{
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 str = TextBox1.Text;
Label2.Text += "SubStrings is:-" + str.Substring(3, 5) + "<br>" +
"lenght:-" + str.Length + "<br>" + "Uppercase:-" + str.ToUpper() +
"<br>" + "Lowercase:-" + str.ToLower() +"<br>"+ "Trim:-" + str.Trim()
+ "<br>" + "Insert:-" + str.Insert(3,"@") +"<br>"+ "Replace:-" +
str.Replace("o", "0");
}

Output:-
Program 1(c): Create an application that receives the
(Student Id, Student Name, Course Name, Date of Birth)
information from a set of students. The application should
also display the information of all the students once the data
entered.
Ans:- using System;
using
System.Collections.Ge
neric; using
System.Linq; using
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button1_Click(object sender, EventArgs e)


{
Label8.Text += "Students Information" + "<br>" + "Student Id:-
"+TextBox1.Text +
"<br>" +"Student Name:-"+TextBox2.Text+" "+TextBox3.Text + "<br>"
+"Course Name:"+TextBox4.Text + "<br>" +"Date Of Birth:-
"+TextBox5.Text + "<br>" +"Phone Number:"+TextBox6.Text + "<br>"
+"Location:-"+TextBox7.Text;
}

protected void Button2_Click(object sender, EventArgs e)


{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
}

Output:-
Program 1(d): Create an application to demonstrate following
operations
I) Fibonacci Series II) Test For
Prime Number III) Test For Vowel
IV) Reverse Of a Number V) Sum Of
Digits.
Ans:- using System;
using
System.Collections.Gen
eric; using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols; namespace
Practical_1_D
{ public partial class WebForm1 :
System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{ int f1 = 0, f2 = 1, f3,
n, co; n=
Convert.ToInt16(TextBox1.Text
);
co = 3;
Label4.Text = f1+"\t"+f2;
while(co<=n)
{
f3 = f1 + f2;
Label4.Text +=
("\t" + f3); f1 =
f2; f2 = f3;
co++;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = " ";
Label4.Text = " ";
}
protected void Button3_Click(object sender, EventArgs e)

{
int n, i,
c;
n = Convert.ToInt16(TextBox2.Text);
for(c=2;c<=n;c++)

{ if
((n % c) == 0)
break;

}
if(n==1)
{
Label8.Text = n + "is neither prime or not composite";
}
else if(c<n-
1)
{
Label8.Text = n +" is not a prime number";

}
else
{
Label8.Text = n + " is a prime number";
}
}
protected void Button4_Click(object sender, EventArgs e)
{
TextBox2.Text = " ";
Label8.Text = " ";
}

protected void Button5_Click(object sender, EventArgs e)


{ string ch;
int count = 0; ch
= TextBox3.Text;
for(int
i=0;i<ch.Length;i++)
{
if((ch.Substring(i,1)=="a") || (ch.Substring(i, 1) == "e") ||
(ch.Substring(i, 1) == "i") || (ch.Substring(i, 1) == "o") ||
(ch.Substring(i, 1) == "u"))

{
count++;
}
}
Label12.Text = "Number Of String: " + count;
}

protected void Button6_Click(object sender, EventArgs e)


{
TextBox3.Text = " ";
Label12.Text = " ";
}

protected void Button8_Click(object sender, EventArgs e)


{
TextBox4.Text = "";
Label18.Text = "";
}

protected void Button7_Click(object sender, EventArgs e)


{ int n, m, r = 0, d,
sum = 0; n=
Convert.ToInt16(TextBox4.Text
); m = n;
while(n>0)

{ d=
n % 10;
r = r * 10 + d;
n = n / 10;
}
Label18.Text += r;
}
protected void Button10_Click(object sender, EventArgs e)
{
TextBox5.Text = " ";
Label20.Text = " ";
}

protected void Button9_Click(object sender, EventArgs e)


{ int n, m, r = 0, d,
sum = 0; n=
Convert.ToInt32(TextBox5.Text
); m = n;
while(n!=0)

{
n /= 10;
sum += 1;
}
Label20.Text += sum;
}
}
}
Output:-
Practical no.2: Working with Object Oriented C# and ASP .NET.
Program 2(a): Create simple application to perform following
operations
i) Finding
factorial Value
ii) Money
Conversion
iii) Quadratic
Equation
iv) Temperature
Conversion
Ans:- [i] Finding Factorial Value

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

namespace factorial
{
class Program
{
static void Main(string[] args)
{
int i, number, fact;
Console.WriteLine("Enter the Number");
number = int.Parse(Console.ReadLine());
fact = number;
for (i = number - 1; i >= 1; i--)
{
fact = fact * i;
}
Console.WriteLine("\nFactorial of Given Number is:
"+fact);
Console.ReadLine();

}
}
}
Output:
Enter the number:- 6
Factorial of given number is.:- 720

[ii] Money Conversion

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

namespace CurrencyConversion
{
class Program
{
static void Main(string[] args)
{
int choice;
Console.WriteLine(&quot;Enter your Choice :\n 1- Dollar to
Rupee \n 2-
Euro to Rupee \n 3- Malaysian
Ringgit to Rupee &quot;); choice
= int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
Double dollar, rupee, val;
Console.WriteLine(&quot;Enter the Dollar
Amount :&quot;); dollar =
Double.Parse(Console.ReadLine());
Console.WriteLine(&quot;Enter the Dollar
Value :&quot;); val =
double.Parse(Console.ReadLine());
rupee = dollar * val;

Console.WriteLine(&quot;{0} Dollar Equals {1}


Rupees&quot;, dollar, rupee); break; case 2:
Double Euro, rupe, valu;
Console.WriteLine(&quot;Enter the Euro Amount :&quot;);
Euro = Double.Parse(Console.ReadLine());
Console.WriteLine(&quot;Enter the Euro
Value :&quot;); valu =
double.Parse(Console.ReadLine());
rupe = Euro * valu;
Console.WriteLine(&quot;{0} Euro Equals {1} Rupees&quot;,
Euro, rupe); break; case 3:
Double ringit, rup, value;
Console.WriteLine(&quot;Enter the Ringgit
Amount :&quot;); ringit =
Double.Parse(Console.ReadLine());
Console.WriteLine(&quot;Enter the Ringgit
Value :&quot;); value =
double.Parse(Console.ReadLine());
rup = ringit * value;
Console.WriteLine(&quot;{0} Malaysian Ringgit Equals {1}
Rupees&quot;, ringit, rup);
break;
}
Console.ReadLine();
}
}
}
2)A)[ii]
Output
[iii] Quadratic Equation

using System;

namespace example
{
class Quadraticroots
{
double a, b, c;

public void read()


{
Console.WriteLine(" \n To find the roots of a quadratic
equation of the form a*x*x + b*x + c = 0");
Console.Write("\n Enter value for
a : "); a=
double.Parse(Console.ReadLine());
Console.Write("\n Enter value for b : ");
b = double.Parse(Console.ReadLine());
Console.Write("\n Enter value for c : ");
c = double.Parse(Console.ReadLine());
}
public void compute()

{ int
m;
double r1, r2, d1;
d1 = b * b - 4 * a * c;
if (a == 0)
m = 1; else if
(d1 > 0) m
= 2; else if
(d1 == 0)
m = 3; else
m = 4;
switch (m)
{
case 1: Console.WriteLine("\n Not a Quadratic equation,
Linear equation");
Console.ReadLine();
break;
case 2: Console.WriteLine("\n Roots are Real and
Distinct");
r1 = (-b + Math.Sqrt(d1)) / (2
* a); r2 = (-b - Math.Sqrt(d1))
/ (2 * a);
Console.WriteLine("\n First root is {0:#.##}", r1);
Console.WriteLine("\n Second root is {0:#.##}", r2);
Console.ReadLine();
break;
case 3: Console.WriteLine("\n Roots are Real and
Equal"); r1 = r2 = (-b) / (2 * a);
Console.WriteLine("\n First root is {0:#.##}", r1);
Console.WriteLine("\n Second root is {0:#.##}", r2);
Console.ReadLine();
break;
case 4: Console.WriteLine("\n Roots are
Imaginary"); r1 = (-b) / (2 * a);
r2 = Math.Sqrt(-d1) / (2 * a);
Console.WriteLine("\n First root is {0:#.##} + i
{1:#.##}", r1, r2); Console.WriteLine("\n Second root
is {0:#.##} - i {1:#.##}", r1, r2);
Console.ReadLine();
break;
}
}
}

class Roots
{
public static void Main()
{
Quadraticroots qr = new Quadraticroots();
qr.read();
qr.compute();
}
}
}

2)A)[iii]

Output:-
[iv] Temperature Conversion

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

namespace temperatureconversion
{
class Program
{
static void Main(string[] args)
{
int celsius, faren;
Console.WriteLine("Enter the Temperature in
Celsius(°C) : "); celsius = int.Parse(Console.ReadLine());
faren = (celsius * 9) / 5 + 32;
Console.WriteLine("0Temperature in Fahrenheit is(°F) : "
+ faren);
Console.ReadLine();
}
}
}
2)A)[iv]
Program 2(b): Create simple application to demonstrate use of
following concepts
i) Function Overloading ii) Inheritance (all types) iii) Constructor
overloading iv) Interfaces
Ans: Function overloading
class Adder

static int multiply(int a,int b)

return a*b;

static int multiply(int a,int b,int c)

return a*b*c;}

class TestOverloading1

public static void main(String[] args)


{

System.out.println(Adder.multiply(110,110));

System.out.println(Adder.multiply(110,110,110));

output:-

ii) Inhertiance (all Types)

1] Single Inheritance:-

class Employee
{
float salary=40000;
}
class Programmer extends Employee
{
int bonus=10000;
public static void main(String args[])
{
Programmer p=new Programmer();
System.out.println("Programmer salary is:"+p.salary);
System.out.println("Bonus of Programmer is:"+p.bonus);
}
}
Output:-

Programmer salary:-40000.0

Bonus of programmer is:-1000 0vsssvsdvsf programmer is:10000


Programmer salary is:40000.0
Bonus of programmer is:10000
Programmer salary is:40000.0
2] MultilevelInheritance

class Student
{
int reg_no;
void getNo(int no)
{
reg_no=no;
}
void putNo()
{
System.out.println("registration number= "+reg_no);
}
}
//intermediate sub class
class Marks extends Student
{
float marks;
void getMarks(float m)
{
marks=m;
}
void putMarks()
{
System.out.println("marks= "+marks);
}
}
//derived class
class Sports extends Marks
{
float score;
void getScore(float scr)
{
score=scr;
}
void putScore()
{
System.out.println("score= "+score);
}
}
public class MultilevelInheritanceExample
{
public static void main(String args[])
{
Sports ob=new Sports();
ob.getNo(0987);
ob.putNo();
ob.getMarks(78);
ob.putMarks();
ob.getScore(68.7);
ob.putScore();
}
}
of programmer is:10000
OUTPUT:-

Registration number=0987
Marks=78.0
Score=68.7
3]Hybrid Inheritance

class C
{
public void disp()
{
System.out.println("C");
}
}

class A extends C
{
public void disp()
{
System.out.println("A");
}
}

class B extends C
{
public void disp()
{
System.out.println("B");
}

class D extends A
{
public void disp()
{
System.out.println("D");
}
public static void main(String args[])
{
D obj = new D();
obj.disp();
}
}
Output:-
D

4]Multiple Inheritance

interface Event {
public void start();
}
interface Sports {
public void play();
}
interface Hockey extends Sports, Event{
public void show();
}
public class Tester{
public static void main(String[] args){
Hockey hockey = new Hockey() {
public void start() {
System.out.println("Start Event");
}
public void play() {
System.out.println("Play Sports.");
}
public void show() {
System.out.println("Show Hockey.");
}
};

hockey.start();
hockey.play();
hockey.show();
}
}

OUTPUT:-

Start Event
Play Sports.
Show Hockey.
Practical no.3: Working with Web Forms and Controls

Program 3(a): Demonstrate the use of Calendar control to


perform following operations
a) Display messages in a calendar control
b) Display vacation in a calendar control
c) Selected day in a calendar control using style
d) Difference between two calendar dates
Ans:-
using System;

System.Collections.Ge
neric; using
System.Linq; using
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Calendar1_SelectionChanged(object sender,


EventArgs e)
{

protected void Calendar1_DayRender(object sender,


DayRenderEventArgs e)
{
if (e.Day.Date.Day == 1 && e.Day.Date.Month == 8)
{
e.Cell.BackColor =
System.Drawing.Color.LightGreen;
Label l1 = new Label(); l1.Text =
"Friendship Day";
e.Cell.Controls.Add(l1);

Image im1 = new Image();


im1.ImageUrl =
"image/friendship day.jpg";
im1.Height = 50; im1.Width =
50;
e.Cell.Controls.Add(im1);
}

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


{
e.Cell.BackColor =
System.Drawing.Color.LightGreen;
Label l1 = new Label(); l1.Text =
"Mother's Day"; e.Cell.Controls.Add(l1);

Image im1 = new Image();


im1.ImageUrl =
"image/Mother Day.jpg";
im1.Height = 50; im1.Width
= 50;
e.Cell.Controls.Add(im1);
}

else if (e.Day.Date.Day == 20 && e.Day.Date.Month == 6)


{
e.Cell.BackColor =
System.Drawing.Color.LightGreen;
Label l1 = new Label(); l1.Text =
"father's Day"; e.Cell.Controls.Add(l1);

Image im1 = new Image();


im1.ImageUrl =
"image/Father Day.jpg";
im1.Height = 50; im1.Width
= 50;
e.Cell.Controls.Add(im1);
}
}

protected void Button1_Click(object sender, EventArgs e)


{
Calendar1.Caption = "Calender 2021";
Label2.Text = "Today's Date is " +
Calendar1.TodaysDate.Date.ToShortDateString();
Label3.Text = "Mother's Day Date is 9-05-2021";
TimeSpan d1 = new DateTime(2021, 5, 9)-DateTime.Now;
Label4.Text = "Remaining Days For Mother's Day is " + d1.Days;
Label5.Text = "Father's Day Date is 20-06-2021";
TimeSpan d2 = new DateTime(2021, 6, 20) - DateTime.Now;
Label6.Text = "Remaining Days For Father's Day is " + d2.Days;
}

Output:-
Program 3(b): Demonstrate the use of Treeview control perform
following operations. a) Treeview control and datalist
b) Treeview operations
Ans:-
Add XML File
Website -> Add -> XML File and Name it ‘stdetail’.

stdetail.xml
<?xml version="1.0" encoding="utf-8" ?>
<studentdetail>
<student>
<sid>1</sid>
<sname>Tushar</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>2</sid>
<sname>Sonali</sname>
<sclass>TYCS</sclass>
</student>
<student>
<sid>3</sid>
<sname>Yashashree</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>4</sid>
<sname>Vedshree</sname>
<sclass>TYCS</sclass>
</student>
</studentdetail>
Default2.aspx
<form id="form1" runat="server">
<div>
Treeview control navigation:<asp:TreeView ID = "TreeView1"
runat =
"server" Width =
"150px" ImageSet="Arrows">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD"
/>
<Nodes>
<asp:TreeNode Text = "ASP.NET Practs" Value = "New Node">
<asp:TreeNode Text = "Calendar Control" Value = "RED"
NavigateUrl="~/calndrCtrl.aspx">
</asp:TreeNode>
<asp:TreeNode Text = "Constructor Overloading" Value =
"GREEN"
NavigateUrl="~/clsconstrc.aspx"></asp:TreeNode>
<asp:TreeNode NavigateUrl="~/singleInh.aspx"
Text="Inheritance"
Value="BLUE"></asp:TreeNode>
<asp:TreeNode NavigateUrl="~/clsProp.aspx" Text="Class
Properties"
Value="Class
Properties"></asp:TreeNode>

</asp:TreeNode>
</Nodes>
<NodeStyle Font-Names="Tahoma" Font-Size="10pt"
ForeColor="Black"
HorizontalPadding="5px" NodeSpacing="0px"
VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True"
ForeColor="#5555DD"
HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>
<br />
Fetch Datalist Using XML data : </div>
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<table class = "table" border="1">
<tr>
<td>Roll Num : <%# Eval("sid") %><br />
Name : <%# Eval("sname") %><br />
Class : <%# Eval("sclass")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
Default2.aspx.cs using
System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}
protected void BindData()
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("stdetail.xml"));
if (ds != null && ds.HasChanges())
{
DataList1.DataSource = ds;
DataList1.DataBind();
}
else
{
DataList1.DataBind();
}
}
}
3)B)b) OUTPUT:-
Practical no.4: Working with Form Controls

Program 4(a): Create a Registration form to demonstrate use of


various Validation control.
Ans:-
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs"
Inherits="Addmission_Form.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
#form1 {}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Font-Size="22pt"
Text="Different Controls"></asp:Label>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Image ID="Image1" runat="server" EnableViewState="False"
GenerateEmptyAlternateText="True" Height="80px"
ImageUrl="~/Image/logo.jpg" Width="79px" />
<br />
<asp:Label ID="Label2" runat="server" Text="Enter First
Name:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server" Width="180px"
> <asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="Please Enter First
Name"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Label3" runat="server" Text="Enter Last
Name"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server" Width="180px"
> <asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server"
ControlToValidate="TextBox2" ErrorMessage="Please Enter Last
Name"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Label4" runat="server" Text="Enter Email
Id:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox3" runat="server" Width="180px"
> <asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server"
ControlToValidate="TextBox3" ErrorMessage="Please Enter Email Id"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Label5" runat="server" Text="Enter
Password:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox4" runat="server"
TextMode="Password" Width="180px"
> <asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server"
ControlToValidate="TextBox4" ErrorMessage="Please Enter
Password"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Label11" runat="server" Text="Select
Country:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:DropDownList ID="DropDownList1" runat="server"
Width="180px"
> <asp:ListItem>Please Selcet Country</asp:ListItem>
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>China</asp:ListItem>
<asp:ListItem>Uk</asp:ListItem>
<asp:ListItem>USA</asp:ListItem>
<asp:ListItem>America</asp:ListItem>
<asp:ListItem>Brazil</asp:ListItem>
<asp:ListItem>Afganistan</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6"
runat="server"
ControlToValidate="DropDownList1" ErrorMessage="Please Select
Country"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Label6" runat="server" Text="Select Todays
Date:"></asp:Label>
<asp:Calendar ID="Calendar1" runat="server"
BackColor="#FFFFCC"
BorderColor="#FFCC66" BorderWidth="1px"
DayNameFormat="Shortest" Font-
Names="Verdana" Font-Size="8pt" ForeColor="#663399"
Height="168px" >ShowGridLines="True"
style="margin-left: 136px; margin-top: 0px" Width="223px">
<DayHeaderStyle BackColor="#FFCC66" Font-Bold="True"
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 />
<asp:Label ID="Label8" runat="server" Text="Select Your
Subjects:"></asp:Label> &nbsp;
<asp:CheckBox ID="CheckBox1" runat="server" Text="Java"
/>
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:CheckBox ID="CheckBox2" runat="server" Text="Python"
/>
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:CheckBox ID="CheckBox3" runat="server" Text="C,C++"
/>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; <asp:CheckBox ID="CheckBox4" runat="server"
Text="Web Programming"
/>
&nbsp;&nbsp;
<asp:CheckBox ID="CheckBox5" runat="server" Text="DBMS"
/>
<br />
<asp:Label ID="Label9" runat="server" Text="Select Your
Semister:"></asp:Label>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:ListBox ID="ListBox1" runat="server" Width="209px"
> <asp:ListItem>Sem 1</asp:ListItem>
<asp:ListItem>Sem 2</asp:ListItem>
<asp:ListItem>Sem 3</asp:ListItem>
<asp:ListItem>Sem 4</asp:ListItem>
<asp:ListItem>Sem 5</asp:ListItem>
<asp:ListItem>Sem 6</asp:ListItem>
</asp:ListBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7"
runat="server"
ControlToValidate="ListBox1" ErrorMessage="Please Select Semister"
ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<asp:Label ID="Label10" runat="server" Text="Select Your
Gender:"></asp:Label> &nbsp;&nbsp;&nbsp;
<asp:RadioButton ID="RadioButton1" runat="server" Text="Male"
>GroupName="gender" />
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:RadioButton ID="RadioButton2" runat="server"
Text="Female"
>GroupName="gender" />
<br />
<asp:Button ID="Button1" runat="server" Text="Reset"
/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;
<asp:Button ID="Button2" runat="server" Text="Submit"
/> </form>
</body>
</html>

WebForm1.aspx.cs:
using System;
using
System.Collections.Ge
neric; using
System.Linq; using
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;

namespace Addmission_Form
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
CheckBox1.Checked = false;
CheckBox2.Checked = false;
CheckBox3.Checked = false;
CheckBox4.Checked = false;
CheckBox5.Checked = false;
Session["java"] = " ";
Session["python"] = " ";
Session["c"] = " ";
Session["wp"] = " ";
Session["dbms"] = " ";
Session["sem"] =" ";
}

protected void Calendar1_SelectionChanged(object sender,


EventArgs e)
{
Session["date"] = Calendar1.SelectedDate.ToShortDateString();
}

protected void TextBox1_TextChanged(object sender, EventArgs e)


{
Session["fname"] = TextBox1.Text;
}

protected void TextBox2_TextChanged(object sender, EventArgs e)


{
Session["lname"] = TextBox2.Text;
}

protected void TextBox3_TextChanged(object sender, EventArgs e)


{
Session["email"] = TextBox3.Text;
}

protected void TextBox4_TextChanged(object sender, EventArgs e)


{
Session["password"] = TextBox4.Text;
}

protected void DropDownList1_SelectedIndexChanged(object


sender, EventArgs e)
{
Session["country"] = DropDownList1.SelectedItem.Text;
}

protected void CheckBox1_CheckedChanged(object sender,


EventArgs e)
{
Session["java"] = CheckBox1.Text;
}
protected void CheckBox2_CheckedChanged(object sender,
EventArgs e)
{
Session["python"] = CheckBox2.Text;
}

protected void CheckBox3_CheckedChanged(object sender,


EventArgs e)
{
Session["c"] = CheckBox3.Text;
}

protected void CheckBox4_CheckedChanged(object sender,


EventArgs e)
{
Session["wp"] = CheckBox4.Text;
}

protected void CheckBox5_CheckedChanged(object sender,


EventArgs e)
{
Session["dbms"] = CheckBox5.Text;
}

protected void RadioButton1_CheckedChanged(object sender,


EventArgs e)
{
Session["gender"] = RadioButton1.Text;
}

protected void RadioButton2_CheckedChanged(object sender,


EventArgs e)
{
Session["gender"] = RadioButton2.Text;
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = " ";
TextBox2.Text = " ";
TextBox3.Text = " ";
TextBox4.Text = " ";
RadioButton1.Checked = false;
RadioButton2.Checked = false;
CheckBox1.Checked = false;
CheckBox2.Checked = false;
CheckBox3.Checked = false;
CheckBox4.Checked = false;
CheckBox5.Checked=false;
}

protected void Button2_Click(object sender, EventArgs e)


{

Response.Redirect("WebForm2.aspx");
}

protected void ListBox1_SelectedIndexChanged(object sender,


EventArgs e)
{
Session["sem"] += ListBox1.Text;
}

WebForm2.aspx.cs:
using System;
using
System.Collections.Ge
neric; using
System.Linq; using
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;

namespace Addmission_Form
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Label7.Text = "Your Selected Subject:-";
Label1.Text += Session["fname"];
Label2.Text += Session["lname"];
Label3.Text += Session["email"];
Label4.Text += Session["password"];
Label5.Text += Session["country"];
Label6.Text += Session["date"];
Label7.Text += Session["java"] + " "+ Session["python"]+" "+
Session["c"] + " "+
Session["wp"] +" "+ Session["dbms"];
Label8.Text += Session["sem"];
Label9.Text += Session["gender"];
}

}
Output:
Program 4(b): Create Web Form to demonstrate use of Adrotator
Control.
Ans:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs"
Inherits="AddRotator.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="AdRotator1" runat="server"
AdvertisementFile="~/XMLFile1.xml"
/>
</div>
</form>
</body>
</html>

XMLFile1.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>~/image/amazone.png</ImageUrl>
<NavigateUrl>https://www.amazon.in/</NavigateUrl>
<AlternateText>Amazone</AlternateText>
<Impression>30</Impression>
<Keywords>Amazone</Keywords>
</Ad>
<Ad>
<ImageUrl>~/image/flipcard.jpg</ImageUrl>
<NavigateUrl>https://www.flipkart.com/</NavigateUrl>
<AlternateText>Flipkart</AlternateText>
<Impression>20</Impression>
<Keywords>Flipkart</Keywords>
</Ad>
<Ad>
<ImageUrl>~/image/Raksha Bandan.jpg</ImageUrl>
<AlternateText>Raksha Bandhan</AlternateText>
<Impression>50</Impression>
<Keywords>Raksha Bandhan</Keywords>
</Ad>
</Advertisements>

Output:
Program 4(c): Create Web Form to demonstrate use User Controls.
Ans:-
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs"
Inherits="UserControl.WebForm1" %>

<% @ Register src="UserControl.ascx" tagname="UserControl"


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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:UserControl ID="UserControl1" runat="server" />
<br />
<asp:ImageMap ID="ImageMap1" runat="server"
Height="200px"
ImageUrl="~/images/welcome.jpg" Width="413px">
</asp:ImageMap>
<br />
<br />
<uc2:WebUserControl2 ID="WebUserControl21" runat="server"
/>
</div>
</form>
</body>
</html>

UserControl.ascx:
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="UserControl.ascx.cs"
Inherits="UserControl.UserControl" %>
<asp:Label ID="Label1" runat="server" Font-Size="20pt" Text="This Is
Header Using User Control 1"></asp:Label>

WebControl2.ascx:
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="WebUserControl2.ascx.cs"
Inherits="UserControl.WebUserControl2" %>
<asp:Label ID="Label1" runat="server" Font-Size="20pt" Text="This Is
Footer Using User
Control 2"></asp:Label>

Output:
Practical no.5: Working with Navigation, Beautification and
Master page.

Program 5(a): Create Web Form to demonstrate use of Website


Navigation controls and Site Map.
Ans:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs"
Inherits="e_next.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style
type="text/css
"> .auto-
style2
{ width:
172px;
height: 51px;
margin-top: 0px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<p>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<img class="auto-style2"
src="image/logo2.jpg" />&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</
p>
<p>
</p>
<p>
</p>
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Menu ID="Menu1" runat="server" BackColor="#F7F6F3"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-
Size="16pt"
ForeColor="#00CC00" Orientation="Horizontal"
StaticSubMenuIndent="10px">
<DynamicHoverStyle BackColor="#7C6F57" ForeColor="White"
/>
<DynamicMenuItemStyle HorizontalPadding="5px"
VerticalPadding="2px" />
<DynamicMenuStyle BackColor="#F7F6F3" />
<DynamicSelectedStyle BackColor="#5D7B9D" />
<DynamicItemTemplate>
<%# Eval("Text") %>
</DynamicItemTemplate>
<Items>
<asp:MenuItem Text="More About Details" Value="More
About Details">
<asp:MenuItem Text="Available Programming Languages
Notes"
Value="Available Programming Languages Notes">
<asp:MenuItem Text="Available All Sem Paper Solution"
Value="Available
All Sem Paper"></asp:MenuItem>
</asp:MenuItem>
</asp:MenuItem>
</Items>
<StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
<StaticMenuItemStyle HorizontalPadding="5px"
VerticalPadding="2px" />
<StaticSelectedStyle BackColor="#5D7B9D" />
<StaticItemTemplate>
<%# Eval("Text") %>
</StaticItemTemplate>
</asp:Menu>
<br />
<br />
<center><asp:Label ID="Label2" runat="server" BackColor="Red"
Font-Size="20pt"
ForeColor="Yellow" Text="Programming Languages
Notes"></asp:Label></center>

<asp:TreeView ID="ProgrammingLang" runat="server" Font-


Size="16pt">
<LeafNodeStyle BorderColor="#FF0066" />
<Nodes>
<asp:TreeNode Text="Select Programming Language">
<asp:TreeNode
NavigateUrl="https://www.tutorialspoint.com/cprogramming/index.
htm" Text="C"
Value="C Lang"></asp:TreeNode>
<asp:TreeNode
NavigateUrl="https://www.tutorialspoint.com/cplusplus/index.htm"
Text="C++"
Value="C++"></asp:TreeNode>
<asp:TreeNode
NavigateUrl="https://www.tutorialspoint.com/html/index.htm"
Text="Html" Value="Html"></asp:TreeNode>
<asp:TreeNode
NavigateUrl="https://www.tutorialspoint.com/css/index.htm"
Text="Css" Value="Css"></asp:TreeNode>
<asp:TreeNode
NavigateUrl="https://www.tutorialspoint.com/javascript/index.htm"
Text="JavaScript"
Value="JavaScript"></asp:TreeNode>
<asp:TreeNode
NavigateUrl="https://www.tutorialspoint.com/python/index.htm"
Text="Python"
Value="Python"></asp:TreeNode>
<asp:TreeNode
NavigateUrl="https://www.tutorialspoint.com/dotnet_core/index.htm
" Text="Dotnet"
Value="Dotnet"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
<RootNodeStyle BorderColor="Red" />
</asp:TreeView><br />

&nbsp;<center><asp:Label ID="Label1" runat="server" Text="For Bsc-


IT Paper Solution" BackColor="Red" Font-Size="20pt"
ForeColor="Yellow"></asp:Label></center>
<p>
<asp:TreeView ID="TreeView1" runat="server"
DataSourceID="SiteMapDataSource1"
> <LeafNodeStyle ForeColor="#FF0066" />
<NodeStyle Font-Size="16pt" ForeColor="Red" />
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1"
runat="server" />
</p>
</form>
</body>
</html>

Web.sitemap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-
File-1.0" >
<siteMapNode title="Select Your Semister" description="Select">
<siteMapNode url="https://e-next.in/bsc-it/sem1/" title="Sem-I"
description="1" />
<siteMapNode url="https://e-next.in/bsc-it/sem2/" title="Sem-II"
description="2" />
<siteMapNode url="https://e-next.in/bsc-it/sem3/" title="Sem-III"
description="3" />
<siteMapNode url="https://e-next.in/bsc-it/sem4/" title="Sem-
IV" description="4" /> <siteMapNode url="https://e-next.in/bsc-
it/sem5/" title="Sem-V" description="5" />
<siteMapNode url="https://e-next.in/bsc-it/sem6/" title="Sem-VI"
description="6" /> </siteMapNode>

</siteMap>

Output:
Program 5(b): Create a web application to demonstrate use of
Master Page with applying Styles and Themes for page
beautification.
Ans:
Site1.master:
<%@ Master Language="C#" AutoEventWireup="true"
CodeBehind="Site1.master.cs" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="title" runat="server">

</asp:ContentPlaceHolder>
<style
type="text/css
"> .auto-
style1
{ width:
1346px;
height: 75px;
align-content:end
}
.auto-
style2
{ width:
106px;
height: 84px;
}
</style>
</head>
<body>
<style
type="text/css">
ul {
list-style-
type: none;
margin: 0;
padding: 0;
overflow:
hidden;
background-
color: #333;
}

l
i

{
float: left;
}

li a
{ disp
lay:
block;
color:
white;
text-align:
right; padding:
14px 16px;
text-decoration:
none;
margin:initial;
}

li a:hover
{ background-
color: white;
color:white
}
.auto-style3 {
width: 1341px;
height: 473px;
}
.auto-
style4
{ width:
1336px;
height: 368px;
}
.auto-
style5
{ width:
1341px;
height: 365px;
}
.auto-
style6
{ width:
1344px;
height: 223px;
}
</style>

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


<div>
<img alt="" class="auto-style1" src="Images/heading.jpg" /><br
/>
<ul>
<li><a class="active" href="#home">Home</a></li>
<li><a href="WebForm2.aspx" >About</a></li>
<li><a href="WebForm3.aspx">Services</a></li>
<li><a href="WebForm4.aspx">Contact</a></li>
</ul>
<img alt="" class="auto-style2" src="Images/logo.jpg"
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
<div style="background-image: url('/Images/1.jpg')">

<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />

</div>
<img alt="" class="auto-style3"
src="Images/dba%20college%202.jpg" /><br />
<br />
<img alt="" class="auto-style4"
src="Images/dba%20college%203.jpg" /><br />
<br />
<img alt="" class="auto-style5"
src="Images/dba%20college%204.jpg" /><br />
<img alt="" class="auto-style6"
src="Images/dba%20college%205.jpg" /></div> </form>
</body>
</html>
WebForm1.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="Dba_College.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title"
runat="server"> </asp:Content>

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<style
type="text/css"> ul
{
list-style-
type: none;
margin: 0;
padding: 0;
overflow:
hidden;
background-
color: #333;
}
li
{ f
loat
:
left;
}

li a
{ disp
lay:
block;
color:
white;
text-align:
right; padding:
14px 16px;
text-decoration:
none;
margin:initial;
}

li a:hover {
background-color: white;
color:white
}
.auto-
style7
{ width:
1341px;
height: 105px;
}
.auto-
style8
{ width:
1343px;
height: 288px;
}
.auto-
style9
{ width:
1340px;
height: 336px;
}
.auto-
style10
{ width:
1342px;
height: 256px;
}
</style>

<div>
<img alt="" class="auto-style1" src="Images/heading.jpg" /><br
/>
<ul>
<li><a class="active" href="WebForm1.aspx">Home</a></li>
<li><a href="#WebForm2.aspx">About</a></li>
<li><a href="WebForm3.aspx">Services</a></li>
<li><a href="WebForm4.aspx">Contact</a></li>
</ul>
<img alt="" class="auto-style2" src="Images/logo.jpg"
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />

<br />
<img alt="" class="auto-style7" src="Images/about1.jpg" /><br
/> <img alt="" class="auto-style8" src="Images/about2.jpg"
/><br />
<img alt="" class="auto-style9" src="Images/about3.jpg" /><br
/>
<img alt="" class="auto-style10"
src="Images/about4.jpg" /></div> </body>
</html>

WebForm3.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm2.aspx.cs"
Inherits="Dba_College.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<style
type="text/css"> ul {
list-style-
type: none;
margin: 0;
padding: 0;
overflow:
hidden;
background-
color: #333;
}

l
i

{
float: left;
}

li a
{ disp
lay:
block;
color:
white;
text-align:
right; padding:
14px 16px;
text-decoration:
none;
margin:initial;
}

li a:hover {
background-color: white;
color:white
}
.auto-
style11
{ width:
1340px;
height:
109px; }
.auto-
style12
{ width:
1342px;
height: 378px;
}
.auto-
style13
{ width:
1343px;
height: 492px;
}
</style>

<img alt="" class="auto-style1" src="Images/heading.jpg" /><br


/>
<ul>
<li><a class="active" href="WebForm1.aspx">Home</a></li>
<li><a href="WebForm2.aspx">About</a></li>
<li><a href="#WebForm3.aspx">Services</a></li>
<li><a href="WebForm4.aspx">Contact</a></li>
</ul>
<img alt="" class="auto-style2" src="Images/logo.jpg"
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
<img alt="" class="auto-style11" src="Images/service1.jpg"
/><br />
<img alt="" class="auto-style12"
src="Images/service2.jpg" /><br /> <img alt=""
class="auto-style13" src="Images/service3.jpg" /><br />
</body>
</html>

WebForm4.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm2.aspx.cs"
Inherits="Dba_College.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<style
type="text/css"> ul {
list-style-
type: none;
margin: 0;
padding: 0;
overflow:
hidden;
background-
color: #333; }
l
i

{
float: left;
}

li a
{ display:
block;
color: white;
text-align:
right;
padding:
14px 16px;
text-
decoration:
none;
margin:initial
;
}

li a:hover {
background-color: white;
color:white
}
.auto-
style11
{ width:
1343px;
height: 109px;
}
.auto-
style12
{ width:
1339px;
height: 481px;
}
.auto-
style13
{ width:
1343px;
height: 145px;
}
</style>

<img alt="" class="auto-style1" src="Images/heading.jpg" /><br


/>
<ul>
<li><a class="active" href="WebForm1.aspx">Home</a></li>
<li><a href="WebForm2.aspx">About</a></li>
<li><a href="WebForm3.aspx">Services</a></li>
<li><a href="#WebForm4.aspx">Contact</a></li>
</ul>
<img alt="" class="auto-style2" src="Images/logo.jpg"
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
<img alt="" class="auto-style11" src="Images/contact1.jpg"
/><br />
<img alt="" class="auto-style12" src="Images/contact2.jpg"
/><br />
<img alt="" class="auto-style13" src="Images/contact3.jpg"
/><br /> </body>
</html>

Output:
Program 5(c): Create a web application to demonstrate various
states of ASP.NET Pages.
Ans:
ViewState.aspx.cs:
using System;
using
System.Collections.Gen
eric; using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;

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

protected void Button1_Click(object sender, EventArgs e)


{
ViewState["country"] = TextBox1.Text;
ViewState["name"] = TextBox2.Text;
TextBox2.Text = TextBox1.Text = string.Empty;
}

protected void Button2_Click(object sender, EventArgs e)


{
if (ViewState["country"] != null)
{
TextBox1.Text = ViewState["country"].ToString();
}
if (ViewState["name"] != null)
{
TextBox2.Text = ViewState["name"].ToString();
}
}

}
SessionState.aspx.cs:
using System;
using
System.Collections.Gen
eric; using System.Linq;
using System.Web;
using System.Web.UI;
using
System.Web.UI.WebCon
trols;

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

protected void Button1_Click(object sender, EventArgs e)


{
Session["country"] = TextBox1.Text;
Session["name"] = TextBox2.Text;
TextBox2.Text = TextBox1.Text = string.Empty;
}

protected void Button2_Click(object sender, EventArgs e)


{
if(Session["country"]!=null)
{
TextBox1.Text = Session["country"].ToString();
}
if(Session["name"]!=null)
{
TextBox2.Text = Session["name"].ToString();
}
}

}
Output:
View State:-
Session State:-
Practical no 6 : a)Create a web application bind data in a multiline
textbox by querying in another textbox.
Default.aspx (create a web page with following design):-

Web.config:-
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntimetargetFramework="4.5.2" />
</system.web>
<connectionStrings>
<add name="connStr" connectionString="Data
Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\Users\tus
hars\Documen ts\Visual Studio
2015\WebSites\Workshop\App_Data\Database.mdf';Integrated
Security=True" />
</connectionStrings>
</configuration>

Default.aspx.cs:-
using System;
usingSystem.Collections.Generi
c; usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebContr
ols; usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Configuration;
public partial class DataBinding : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
stringconnStr =
ConfigurationManager.ConnectionStrings["connStr"].Conne
ctionStrin g;
SqlConnection con = new SqlConnection(connStr);
con.Open();
SqlCommandcmd = new SqlCommand(TextBox1.Text, con);
SqlDataReader reader = cmd.ExecuteReader();
ListBox1.Items.Clear();
while (reader.Read())
{
//To add new blank line in the text area

for (int i = 0; i <reader.FieldCount - 1; i++)


{
ListBox1.Items.Add(reader[i].ToString());
}
}
reader.Close();
con.Close();
}
}
6a ) output:-
6 b)Create a web application to display records by using
database.
Default.aspx (create a web page with following design):-

Default.aspx.cs :-
protected void Button1_Click(object sender, EventArgs e)
{
stringconnStr =
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
SqlCommandcmd = new SqlCommand("Select City, State from
Customer", con);
con.Open();
SqlDataReader reader =
cmd.ExecuteReader(); while (reader.Read())
{
Label1.Text += reader["City"].ToString() + " " +
reader["State"].ToString() +
"<br>";
}
reader.Close();
con.Close();
}
6 b ) output
6 (c): Demonstrate the use of Datalist link control.
steps
1. Drag the Datalist control to our web page form
toolbox->Data->Datalist.
2. Then select Choose Data Source Option and select <New Data
Source>.

3. Now Select SQL Database from options and Click Ok button.

4. In next window click on New Connection button.


5. In add connection window Select the available SQL Server Name
6. Keep the Authentication as Windows Authentication.

7. After that select Attach a Database file radio button. Here we have
to select the database that we have created in our application.
(Usually it will be in Documents folder under Visual Studio 2015/
Websites).
8. After selection of Database file. We can also Test the connection.

9. Then Click on OK button.

10. Once the Connection is made then click on Next button from Data
Source Wizard.
11. Then wizard ask for saving the connection string in configuration
file. If you already stored it web.config file then uncheck check box,
if you haven’t, then select the checkbook. Then click on next
button.
12. The next screen gives option to configure the select statement.
Here we can choose the table as well as configure the select
statement as we need to display the data on web page.

13. In next screen we can test our query to check the output. Then
Click on finish.
Practical no 7:- (a): Create a web application to display Databinding
using Dropdownlist control.
Default.aspx (create a web page with following design):-
1. Create a web page with DropDownList control, one Button and one
Label control.
2. Use code to bind the data to DropDownList.

Default.aspx.cs:-
using System;
usingSystem.Collections.Generi
c; usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebContro
ls; usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Configuration;
public partial class DBDropDown : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
stringconnStr =
ConfigurationManager.ConnectionStrings["connStr"].
Connecti onString;
SqlConnection con = new SqlConnection(connStr);
SqlCommandcmd = new SqlCommand("Select Distinct City
from Customer", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataTextField =
"City";
DropDownList1.DataBind();
reader.Close();
con.Close();
}

protected void Button1_Click(object sender, EventArgs e)


{
Label1.Text = "The You Have Selected : " +
DropDownList1.SelectedValue; }}
7 a) output:-
7 (b): Create a web application for to display the phone no of an
author using database.
Default.aspx (create a web page with following design):-
Create a web page with DropDownList, Button and with Label control
as shown below.

Default.aspx.cs:-
using System;
usingSystem.Collections.Generi
c; usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebContr
ols; usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Configuration;

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


{
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = ListBox1.SelectedValue;

}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
stringconnStr =
ConfigurationManager.ConnectionStrings["connStr"].
Connecti onString;
SqlConnection con = new SqlConnection(connStr);
SqlCommandcmd = new SqlCommand("Select
Distinct POSTAL_CODE from Customer", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
ListBox1.DataSource = reader;
ListBox1.DataTextField = "City";
ListBox1.DataValueField = "POSTAL_CODE";
ListBox1.DataBind(); reader.Close();
con.Close();

}
}
}
7b) output :-
7 (c): Create a web application for inserting and deleting record
from a database. (Using Execute-Non Query).
Default.aspx (create a web page with following design):-

Default.aspx.cs:-
using System;
usingSystem.Collections.Generic;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Configuration;
public partial class ExecuteNonQuery : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
stringconnStr =
ConfigurationManager.ConnectionStrings["connStr"].Conne
ctionStrin g; SqlConnection con = new
SqlConnection(connStr); string InsertQuery = "insert
into BRANCH values(@ADDRESS, @CITY, @NAME,
@STATE, @ZIP_CODE)";
SqlCommandcmd = new SqlCommand(InsertQuery, con);
cmd.Parameters.AddWithValue("@ADDRESS",
TextBox1.Text);
cmd.Parameters.AddWithValue("@CITY", TextBox2.Text);
cmd.Parameters.AddWithValue("@NAME", TextBox3.Text);
cmd.Parameters.AddWithValue("@STATE", TextBox4.Text);
cmd.Parameters.AddWithValue("@ZIP_CODE",
TextBox5.Text); con.Open();
cmd.ExecuteNonQuery();
Label1.Text = "Record Inserted Successfuly.";
con.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
stringconnStr =
ConfigurationManager.ConnectionStrings["connStr"].Conne
ctionStrin g; SqlConnection con = new
SqlConnection(connStr); stringInsertQuery = "delete
from branch where NAME=@NAME";
SqlCommandcmd = new SqlCommand(InsertQuery, con);
cmd.Parameters.AddWithValue("@NAME", TextBox1.Text);
con.Open( );
cmd.ExecuteNonQuery( );
Label1.Text = "Record Deleted Successfuly.";
con.Close( ); } }
Practical no.8 a) Create a web application to demonstrate
Various uses and properties of SQL Data Source.

1. File→new→website→empty website→name it→ok


2. Right click on website made→add new item→sql server database→name
it→add→yes
3. Right click on table In server explorer→add new table→add
columns→save the table
4. Right click on table made →show table data→add values
5. Right click on website→add new item→webform→name it
6. Go to design view→add form for login
7. Add sqldatasource→configure it
8. Write code

CODE:

LoginModule.asp
x using System;
using
System.Collections.Gener
ic; using System.Linq;
using System.Web; using
System.Web.UI; using
System.Web.UI.WebContr
ols;
public partial class LoginModule : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSignUp_Click(object sender, EventArgs e)
{
SqlDataSource1.InsertParameters["Username"].DefaultValue =
txtUserName.Text;
SqlDataSource1.InsertParameters["Password"].DefaultValue =
txtPassword.Text;
SqlDataSource1.Insert();
lblResult.Text = "User Added";
}
}
OUTPUT:
8)b) Create a web application To demonstrate data binding using
DetailsView and FormView control.
using System; using
System.Data; using
System.Data.SqlClient;
using System.Linq;
using System.Web; using
System.Web.UI; using
System.Web.UI.WebControls;
using
System.Collections.Generic;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
SqlDataAdapter da = new SqlDataAdapter();
SqlConnection con = new SqlConnection();
SqlCommand cmd = new
SqlCommand(); DataSet ds = new
DataSet(); string str;
protected void Page_Load(object sender, EventArgs e)
{
con.ConnectionString = "Data
Source=(LocalDB)\\v11.0;AttachDbFilename=C:\\Users\\SAHIL\\D
ocuments\\Stud ents.mdf;Inte
grated Security=True;Connect Timeout=30";
con.Open();
Label4.Text = "Connected To Server";
con.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
str = "insert into stud_mast values(" + TextBox1.Text + " , ' " +
TextBox2.Text + " ' , " +
TextBox3.Text + ")";
con.Open();
cmd = new
SqlCommand(str,con);
cmd.ExecuteNonQuery();
con.Close();
Label4.Text = " Save Successfull ";

TextBox1.Text = " ";


TextBox2.Text = " ";
TextBox3.Text = " ";
}
protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{
}
protected void Button4_Click(object sender, EventArgs e)
{
str = "select * from stud_mast where stud_id= " +
DropDownList1.Text + " "; da = new SqlDataAdapter(str, con); ds
= new DataSet(); da.Fill(ds,"stud_mast");
TextBox1.Text =
ds.Tables["stud_mast"].Rows[0]["stud_id"].ToString();
TextBox2.Text =
ds.Tables["stud_mast"].Rows[0]["stud_name"].ToString();
TextBox3.Text =
ds.Tables["stud_mast"].Rows[0]["phn_no"].ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
str = "update stud_mast set stud_name= ' " + TextBox2.Text + " ',
phn_no= "
+TextBox3.Text+" where stud_id= "+DropDownList1.Text+" ";
con.Open();
cmd = new SqlCommand(str,
con); cmd.ExecuteNonQuery();
con.Close();
Label4.Text = " Update Successfull ";
}
protected void Button3_Click(object sender, EventArgs e)
{
str = "delete from stud_mast where stud_id=" + DropDownList1.Text +
" "; con.Open();
cmd = new SqlCommand(str,
con); cmd.ExecuteNonQuery();
con.Close();
Label4.Text = " Update Successfull ";
}}}
Output:-
PRACTICAL 9 (a)Create a web application to demonstrate use of
GridView button column and GridView events.
Grid_view.aspx:-

Grid_view.aspx.cs:-
using System;
usingSystem.Collections.Generi
c; usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebContr
ols; usingSystem.Drawing;
public partial class grid_view : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "b1")
{
Response.Write(e.CommandName);

GridView1.SelectedRowStyle.BackColor=System.Drawing.Color.Brow
n;
GridView1.Rows[Convert.ToInt16(e.CommandArgument)].BackColor
=
System.Drawing.Color.Blue;
}
}
}
output:-
9(b) Create a web application to demonstrate use of GridView
control template and GridView probelm with solution
ANS:-
<%@ Register TagPrefix="my" TagName="GenericGridView"
Src="~/GenericGridView.ascx" %>

<my:GenericGridView runat="server" ID="myGV" AllowPaging="true"


AllowSorting="true"
/>
protected void GridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
var thc = new TableHeaderCell();
thc.Text = "Click Me";
e.Row.Cells.Add(thc);
}

if ( e.Row.RowType == DataControlRowType.DataRow)
{
var tc = new TableCell();
tc.Controls.Add(new CheckBox());
e.Row.Cells.Add(tc);
}
}

Output:-

You might also like