Ayush Awp

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

Ayush Dhumal

Roll No:10

ADVANCE WEB
PROGRAMMING
JOURNAL 2024-2025

NAME: Ayush Dhumal


ROLL NO: 10
Class: TY Bsc.IT

1|Page
Ayush Dhumal
Roll No:10

INDEX
Sr.no Topic Date Sign
1 Working with basic C# and ASP.NET

2 Web page to demonstrate Server controls.

3 Working with Form Controls

A) Registration form to demonstrate validation


controls

B) Web form to demonstrate Adrotator Controls

4 Working with beautification and Master pages

A) A Web application to demonstrate Master Page


with style and themes

B) Web application to demonstrate various States


of ASP.NET Pages.

5 Working with Databases

A) A Web application to Bind data in a Multiline


textbox to querying in another textbox.

B) Web application to display records by using


database

c) Demonstrate the use of Datalist link control.

2|Page
Ayush Dhumal
Roll No:10

6 Working with Databases

A) A Web application to display Databinding using


Dropdownlist contol

B) Web application to display Title of an Employee


using database

7 Data Access and Data Binding

A) Web Application to display data using


Disconnected Data Access and Data
Binding using GridView control

B) Web Application to display data using


Disconnected Data Access and Data
Binding using FormView control

c) Web Application to display data using


Disconnected Data Access and Data
Binding using DetailView control

8A Web application to demonstrate Form Security


with Authentication and Authorization.

8B Web application to demonstrate to


demonstrate use of various Ajax Controls.

9 Programs to create and use DLL.

10 Create a web application for User defined


exception handling.

3|Page
Ayush Dhumal
Roll No:10

Practical No: 1A
Aim: Create an application to print on screen the output of adding, subtracting,
multiplying and dividing two numbers entered by the user.

Source Code:

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

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

/><br />

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


/><br
/>

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

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

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

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

</div>

</form>

4|Page
Ayush Dhumal
Roll No:10

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

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

int addition, subtraction, multiplication, division; addition =

Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text); subtraction =

Convert.ToInt32(TextBox1.Text) - Convert.ToInt32(TextBox2.Text); multiplication =

Convert.ToInt32(TextBox1.Text) * Convert.ToInt32(TextBox2.Text); division =

Convert.ToInt32(TextBox1.Text) / Convert.ToInt32(TextBox2.Text);

5|Page
Ayush Dhumal
Roll No:10

Label1.Text = "Addition of the number is: " + addition;

Label2.Text = "Subtraction of the number is: " + subtraction;

Label3.Text = "Multiplication of the number is: " + multiplication;

Label4.Text = "Division of the numner is: " + division;

Output:

6|Page
Ayush Dhumal
Roll No:10

Practical No: 1B
Aim: Create an application to demonstrate following operations.

1) Generate Fibonacci Series.

2) Prime Number.

Source Code:
1) Generate Fibonacci Series.

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

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

<asp:Button ID="Button1" runat="server" Text="Fibonacci Series" onclick="Button1_Click"

/><br /><br />

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

</div>

7|Page
Ayush Dhumal
Roll No:10

</form>

</body>

</html>

Default.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

{ int a, b, c, i, n; a =

0; b = 1;

Label1.Text = a.ToString() + b.ToString();

n = Convert.ToInt32(TextBox1.Text);

for (i = 1; i <= n; i++)

c = a + b;

8|Page
Ayush Dhumal
Roll No:10

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

a = b; b = c;

Output:

9|Page
Ayush Dhumal
Roll No:10

2) Prime Number.

Source Code:

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

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

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


/>

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

</div>

</form>

</body>

</html>

10 | P a g e
Ayush Dhumal
Roll No:10

Default.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

{ int n, i, s = 0;

n = Convert.ToInt32(TextBox1.Text);

if (n == 0 || n == 1) s = 1; for (i = 2; i

<= n / 2; i++)

if (n % i == 0)

s = 1;

break;

11 | P a g e
Ayush Dhumal
Roll No:10

if (s == 0)

Label1.Text = "The given number is prime number";

else

Label1.Text = "The given number is not prime number";

Output:

12 | P a g e
Ayush Dhumal
Roll No:10

13 | P a g e
Ayush Dhumal
Roll No:10

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

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

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

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

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

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

Mobile.no: <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox><br /><br /> Subject:<br

/>

<asp:CheckBox ID="CheckBox1" runat="server" Text="Awp" /><br /><br />

<asp:CheckBox ID="CheckBox2" runat="server" Text="Spm"/><br /><br />

<asp:CheckBox ID="CheckBox3" runat="server" Text="IOT"/><br /><br />

<asp:CheckBox ID="CheckBox4" runat="server" Text="AI"/><br /><br />

14 | P a g e
Ayush Dhumal
Roll No:10

<asp:CheckBox ID="CheckBox5" runat="server" Text="NGT" /><br /><br />

<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" /> &nbsp;


&nbsp;

<asp:Button ID="Button2" runat="server" Text="Cancel" onclick="Button2_Click" /><br /><br


/>

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

</div>

</form>

</body>

</html>

15 | P a g e
Ayush Dhumal
Roll No:10

Default.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

Label1.Text += "First Name :" + TextBox1.Text + "<br />";

Label1.Text += "Last Name : " + TextBox2.Text + "<br />";

Label1.Text += "Class : " + TextBox3.Text + "<br />";

Label1.Text += "Address : " + TextBox4.Text + "<br />";

Label1.Text += "Mobile No : " + TextBox5.Text + "<br />";

Label1.Text += "Subject : <br />"; if (CheckBox1.Checked

== true)

Label1.Text += CheckBox1.Text + "<br />"; if

(CheckBox2.Checked == true)

16 | P a g e
Ayush Dhumal
Roll No:10

Label1.Text += CheckBox2.Text + "<br />"; if

(CheckBox3.Checked == true)

Label1.Text += CheckBox3.Text + "<br />"; if

(CheckBox4.Checked == true)

Label1.Text += CheckBox4.Text + "<br />"; if

(CheckBox5.Checked == true)

Label1.Text += CheckBox5.Text + "<br />";

protected void Button2_Click(object sender, EventArgs e)

TextBox1.Text = "";

TextBox2.Text = "";

TextBox3.Text = "";

TextBox4.Text = "";

TextBox5.Text = "";

CheckBox1.Checked = false;

CheckBox2.Checked = false;

CheckBox3.Checked = false;

CheckBox4.Checked = false;

CheckBox5.Checked = false;

Label1.Text = "";

17 | P a g e
Ayush Dhumal
Roll No:10

18 | P a g e
Ayush Dhumal
Roll No:10

Output:

19 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 3A
Working with form Controls

Pract 4 A)
Aim : Create a Registration form to demonstrate use of various Validation
Controls.

Source Code:

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

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

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


ErrorMessage="Field Required" ControlToValidate="TextBox1"></asp:RequiredFieldValidator><br
/><br />

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

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


is Required" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>

20 | P a g e
Ayush Dhumal
Roll No:10

<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="age should be


between 18-25 " ControlToValidate="TextBox2" MaximumValue="25"
MinimumValue="18"></asp:RangeValidator><br /><br />

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

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


ErrorMessage="Field Required" ControlToValidate="TextBox3"></asp:RequiredFieldValidator><br /><br
/>

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

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


ErrorMessage="Field Required" ControlToValidate="TextBox4"></asp:RequiredFieldValidator>

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


ErrorMessage="Email should have @" ControlToValidate="TextBox4"
ValidationExpression=".+@.+"></asp:RegularExpressionValidator><br /><br />

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

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


ErrorMessage="RequiredField" ControlToValidate="TextBox5"></asp:RequiredFieldValidator><br /><br
/>

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


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

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


ErrorMessage="RequiredField" ControlToValidate="TextBox6"></asp:RequiredFieldValidator><br />

<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="password not


matched" ControlToValidate="TextBox6"
ControlToCompare="TextBox5"></asp:CompareValidator><br /><br />

<asp:Button ID="Button2" runat="server" Text="Submit" onclick="Button1_Click" />

21 | P a g e
Ayush Dhumal
Roll No:10

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

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

</div>

</form>

</body>

</html>

OUTPUT:

22 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 3B
Aim: Create Web Form to demonstrate use of Adrotator Control Source

Code:

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

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

</asp:ScriptManager>

<asp:Timer ID="Timer1" Interval="5000" runat="server">

</asp:Timer>

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

<Triggers>

<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />

</Triggers>

23 | P a g e
Ayush Dhumal
Roll No:10

<ContentTemplate>

<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/XMLFile.xml"/>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

</body>

</html>

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

<Advertisements>

<Ad>

<ImageUrl>~/image/google.jpeg</ImageUrl>

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

<AlternateText>

Pls visit google.com

</AlternateText>

</Ad>

<Ad>

<ImageUrl>~/image/facebook.jpeg</ImageUrl>

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

<AlternateText>

24 | P a g e
Ayush Dhumal
Roll No:10

Pls visit facebook.com

</AlternateText>

</Ad>

<Ad>

<ImageUrl>~/image/whatsapp.jpeg</ImageUrl>

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

<AlternateText>

Pls visit whatsapp.com

</AlternateText>

</Ad>

</Advertisements>

25 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:

26 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 4A
Aim: Create a web application to demonstrate use of Master Page with applying
Style and themes for page beautification.
->Create a Master page

Source Code:

MasterPage.master

->Create a Home Form

Home.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Home.aspx.cs" Inherits="Home" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<h1>Welcome to Siddharth College Of Commerce & Economics </h1>

<h2>Fort,Mumbai

400006</h2>

</asp:Content>

27 | P a g e
Ayush Dhumal
Roll No:10

->Create a Registration Form

Registration.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Registration.aspx.cs" Inherits="Registration" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<h1>Registration Form</h1>

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

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

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

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

<asp:Button ID="Button1" runat="server" Text="Register" /> &nbsp; &nbsp;

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

</asp:Content>

->Create a Login Form

Login.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Login.aspx.cs" Inherits="Login" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

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

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

<asp:Button ID="Button1" runat="server" Text="Login" /> &nbsp;&nbsp;

28 | P a g e
Ayush Dhumal
Roll No:10

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

</asp:Content>

->Create a AboutUs Form

AboutUs.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="AboutUs.aspx.cs" Inherits="AboutUs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<h3>Introduction:</h3>

<p>Siddharth College of Commerce and Economics, established in 1953, recognized under Sections
2(f) and 12 (B) of the UGC Act is one of the premier affiliated Colleges of the University of Mumbai.

Our College was the first Commerce College started by the People's Education Society and is the second
oldest Commerce College in Mumbai.

The College is situated in South Mumbai which is the financial heart of Mumbai and India.

Institutions like the RBI Headquarters, the Bombay Stock Exchange and the head offices of many
nationalized banks,

including the SBI are within walking distance of the College.</p>

<u>The College building, Anand Bhavan (formerly Albert Building) is a Grade II Heritage structure.

The built-in area includes the College office the offices of the Self-financed Programmes, the library, 3
computer labs, the Examination department,

the NCC, NSS and Gymkhana rooms, the Principal's cabin, Professors' Common Room, 14 other class
roooms and 1 small room for tutorials as well as

29 | P a g e
Ayush Dhumal
Roll No:10

the Ph.D. Research Centre. The library lends itself to a quiet and reflective ambience for the students as
well as the faculty members.

It is well-stocked with books. Besides this, the College also has 8 additional classrooms and one Staff
Room in Municipal School Building,

Sindhi Lane, which is used for conducting Examinations.</u>

<b>The College provides proper guidance to the students not only to help them choose the right career
path,

but also to help them in becoming confident and emotionally secure individuals. The College is
committed to making students conscious

of their social responsibility through outreach programmes organized by NSS and NCC which enhance
students' social awareness and sensitivity

towards the upliftment of the underprivileged sections of the society. It also helps them discover hidden
talents through sports and cultural activities.</b>

</asp:Content>

30 | P a g e
Ayush Dhumal
Roll No:10

StyleSheet.css
body

background-color:Gray;

background-image:url(clg.jpg) }

h1{ color:Yellow; font-family:Arial;

font-size:medium; text-

align:center; } h2{ color:Red; font-

family:Arial; font-size:medium; }

p{ color:Green; } b{ color:Orange;

SkinFile.skin
<%--

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

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

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

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

<AlternatingRowStyle BackColor="Blue" />

</asp:GridView>

31 | P a g e
Ayush Dhumal
Roll No:10

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:TextBox runat="server" BackColor="Aqua" BorderWidth="3px" BoarderStyle="Dashed"/>

<asp:Button runat="server" BackColor="Blue" BorderWidth="3px" BoarderStyle="Dotted"/>

Output:

32 | P a g e
Ayush Dhumal
Roll No:10

33 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 4B
Aim : Create a web application to demonstrate various States of ASP.NET pages.

Source Code:
1) ViewState:

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

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


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

34 | P a g e
Ayush Dhumal
Roll No:10

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

<asp:Button ID="Button1" runat="server" Text="GetData" onclick="Button1_Click"

/>

</div>

</form>

</body>

</html>

Default.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

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

35 | P a g e
Ayush Dhumal
Roll No:10

protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)

string str = "TY BSC_IT"; if

(ViewState["name"] == null)

ViewState["name"] = str;

protected void Button1_Click(object sender, EventArgs e)

Label1.Text = ViewState["name"].ToString();

OUTPUT:

36 | P a g e
Ayush Dhumal
Roll No:10

2) Cookies

Cookies.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cookies.aspx.cs" Inherits="Default2" %>

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


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

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

<head runat="server">

<title></title>

</head>

37 | P a g e
Ayush Dhumal
Roll No:10

<body id="BodyTag" runat="server">

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

<div>

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

onselectedindexchanged="DropDownList1_SelectedIndexChanged">

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

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

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

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

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

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

</asp:DropDownList>

</div>

</form>

</body>

</html>

Cookies.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

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

38 | P a g e
Ayush Dhumal
Roll No:10

protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)

if (Request.Cookies["BackgroundColor"] != null)

DropDownList1.SelectedValue = Request.Cookies["BackgroundColor"].Value;

BodyTag.Style["background-color"] = DropDownList1.SelectedValue;

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

BodyTag.Style["background-color"] = DropDownList1.SelectedValue;

HttpCookie cookie = new

HttpCookie("BackgroundColor"); cookie.Value =

DropDownList1.SelectedValue; cookie.Expires =

DateTime.Now.AddMilliseconds(5);

Response.Cookies.Add(cookie);

Response.SetCookie(cookie);

39 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:

3) Querystring

Querystring.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Querystring.aspx.cs"
Inherits="Querystring" %>

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

40 | P a g e
Ayush Dhumal
Roll No:10

<title></title>

</head>

<body>

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

<div>

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

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

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

</div>

</form>

</body>

</html>

Querystring.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

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

protected void Page_Load(object sender, EventArgs e)

41 | P a g e
Ayush Dhumal
Roll No:10

protected void Button1_Click(object sender, EventArgs e)

Response.Redirect("Default2.aspx?UserId=" + TextBox1.Text + "&Password=" + TextBox2.Text);

Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

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

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

</div>

42 | P a g e
Ayush Dhumal
Roll No:10

</form>

</body>

</html>

Default2.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

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

protected void Page_Load(object sender, EventArgs e)

if (!IsPostBack)

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

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

43 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:

44 | P a g e
Ayush Dhumal
Roll No:10

4) Session and Application State

Golbal.aspx
<%@ Application Language="C#" %>

<script runat="server"> void Application_Start(object

sender, EventArgs e)

Application["user"] = 0;

void Application_End(object sender, EventArgs e)

void Application_Error(object sender, EventArgs e)

void Session_Start(object sender, EventArgs e)

Application.Lock();

45 | P a g e
Ayush Dhumal
Roll No:10

Application["user"] = (int)Application["user"] + 1;

Application.UnLock();

void Session_End(object sender, EventArgs e)

Application.Lock();

Application["user"] = (int)Application["user"] - 1;

Application.UnLock();

</script>

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

</system.web>

</configuration>

46 | P a g e
Ayush Dhumal
Roll No:10

SessionApplicationt.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SessionApplication.aspx.cs"
Inherits="SessionApplication" %>

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

Visitors Count:<%=Application["user"].ToString() %>

</div>

47 | P a g e
Ayush Dhumal
Roll No:10

</form>

</body>

</html>

OUTPUT:

48 | P a g e
Ayush Dhumal
Roll No:10

Practical 5 : Working with Database

Practical No: 5A
Aim: Create a web application bind data in a multiline textbox by querying in
another textbox.

Source Code:

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

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


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

49 | P a g e
Ayush Dhumal
Roll No:10

<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="56px" TextMode="MultiLine"

Width="272px"></asp:TextBox><br /><br />

<asp:TextBox ID="TextBox2" runat="server" Height="317px"

style="margin-right: 0px" TextMode="MultiLine" Width="493px"></asp:TextBox><br


/><br />

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

onclick="Button1_Click" /><br /><br />

</div>

</form>

</body>

</html>

Default.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI; using

System.Web.UI.WebControls; using

50 | P a g e
Ayush Dhumal
Roll No:10

System.Data.SqlClient; using

System.Configuration; using

System.Data;

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 conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

SqlConnection con = new SqlConnection(conn); con.Open();

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

SqlDataReader r = cmd.ExecuteReader();

TextBox2.Text = " ";

while (r.Read())

TextBox2.Text += Environment.NewLine;

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

TextBox2.Text += r[i].ToString().PadRight(10);

51 | P a g e
Ayush Dhumal
Roll No:10

r.Close();

con.Close();

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="false" targetFramework="4.0" />

</system.web>

<connectionStrings>

52 | P a g e
Ayush Dhumal
Roll No:10

<add name="conn" connectionString="Data


Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\sneha\OneDrive\Documents\Visual Studio
2010\WebSites\WebSite1\App_Data\Database.mdf;Integrated Security=True;User Instance=True" />

<add name="ConnectionString" connectionString="Data


Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User
Instance=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

</configuration>

53 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:

54 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 5B
Aim: create an application to display records by using Database.

Source Code:

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

<!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="getdata" onclick="Button1_Click"

/><br /><br />

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

</div>

</form>

</body>

</html>

55 | P a g e
Ayush Dhumal
Roll No:10

Default.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI; using

System.Web.UI.WebControls; using

System.Data; using

System.Data.SqlClient; using

System.Configuration;

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

String conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

SqlConnection con = new SqlConnection(conn);

con.Open();

56 | P a g e
Ayush Dhumal
Roll No:10

SqlCommand cmd = new SqlCommand("Select Id,Name,Age,Address from Customer", con);

SqlDataReader r = cmd.ExecuteReader();

Label2.Text = " ";

while (r.Read())

Label2.Text += r["Id"].ToString() + " " + r["Name"].ToString()+ " " + r["Address"].ToString()


+ "<br>";

r.Close();

con.Close();

57 | P a g e
Ayush Dhumal
Roll No:10

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="false" targetFramework="4.0" />

</system.web>

<connectionStrings>

<add name="conn" connectionString="Data


Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\sneha\OneDrive\Documents\Visual Studio
2010\WebSites\WebSite1\App_Data\Database.mdf;Integrated Security=True;User Instance=True" />

<add name="ConnectionString" connectionString="Data


Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User
Instance=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

</configuration>

58 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:

59 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 5C
Aim: Demonstrate the use of DataList link Control

Steps:

1. Do all the Database related steps done in practicals 6a and 6b.

2. Write connection string in web.config file

3. Add a web form

4. Drag and drop a datalist from Data control from Toolbox

5. Do the following steps.

Source Code:

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

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

60 | P a g e
Ayush Dhumal
Roll No:10

<ItemTemplate>

Id:

<asp:Label ID="IdLabel" runat="server" Text='<%# Eval("Id") %>' />

<br />

Name:

<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />

<br />

Age:

<asp:Label ID="AgeLabel" runat="server" Text='<%# Eval("Age") %>' />

<br />

Address:

<asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' />

<br />

<br />

</ItemTemplate>

</asp:DataList>

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

ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

SelectCommand="SELECT * FROM [Customer]"></asp:SqlDataSource>

</div>

</form>

</body>

</html>

61 | P a g e
Ayush Dhumal
Roll No:10

62 | P a g e
Ayush Dhumal
Roll No:10

63 | P a g e
Ayush Dhumal
Roll No:10

64 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:

65 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 6A
Aim: Create a simple web page with various server controls to
demonstrate setting and use of their properties.(Example : AutoPostBack)
Source Code:

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

<!DOCTYPE html>

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList><br /><br />

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


/>

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

</div>

</form>

</body>

66 | P a g e
Ayush Dhumal
Roll No:10

</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.Configuration; using

System.Data;

using System.Data.SqlClient;

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

protected void Page_Load(object sender, EventArgs e)

if (IsPostBack == false)

string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

SqlConnection con = new SqlConnection(conn); con.Open();

SqlCommand cmd = new SqlCommand("select city from Customer", con);

SqlDataReader r = cmd.ExecuteReader();

DropDownList1.DataSource = r;

67 | P a g e
Ayush Dhumal
Roll No:10

DropDownList1.DataTextField = "city";

DropDownList1.DataBind();

r.Close();

con.Close();

protected void Button1_Click(object sender, EventArgs e)

Label1.Text = "The City you have selected is" + DropDownList1.SelectedValue;

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>

68 | P a g e
Ayush Dhumal
Roll No:10

<system.web>

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

<httpRuntime targetFramework="4.5.2" />

</system.web>

<connectionStrings>

<add name="conn" connectionString="Data


Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\admin\Documents\Visual Studio
2015\WebSites\pract7\App_Data\Database.mdf;Integrated Security=True"/>

</connectionStrings>

</configuration>

Output:-

69 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 6B
Aim: Create a simple web page with various server controls to
demonstrate setting and use of their properties.(Example : AutoPostBack)
Source Code:

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

<!DOCTYPE html>

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList><br /><br />

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


/>

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

</div>

</form>

</body>

</html>

70 | P a g e
Ayush Dhumal
Roll No:10

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;

using System.Data.SqlClient;

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

protected void Page_Load(object sender, EventArgs e)

if (IsPostBack == false)

string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

SqlConnection con = new SqlConnection(conn); con.Open();

SqlCommand cmd = new SqlCommand("select name,city from Customer", con);

SqlDataReader r = cmd.ExecuteReader();

DropDownList1.DataSource = r;

DropDownList1.DataValueField = "city";

71 | P a g e
Ayush Dhumal
Roll No:10

DropDownList1.DataTextField = "name";

DropDownList1.DataBind();

r.Close();

con.Close();

protected void Button1_Click(object sender, EventArgs e)

Label1.Text = "The City you have selected is " + DropDownList1.SelectedValue;

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

<httpRuntime targetFramework="4.5.2" />

</system.web>

<connectionStrings>

72 | P a g e
Ayush Dhumal
Roll No:10

<add name="conn" connectionString="Data


Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\admin\Documents\Visual Studio
2015\WebSites\pract7\App_Data\Database.mdf;Integrated Security=True"/>

</connectionStrings>

</configuration>

Output:-

73 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 7A
Aim: Web Application to display data using Disconnected Data Access and
Data Binding using GridView control Source Code:

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-


transitional.dtd">

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:Button ID="Button1" runat="server" Text="Get disconnected data" onclick="Button1_Click"

/><br /><br />

<asp:GridView ID="GridView1" runat="server" BackColor="White"

BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3"

GridLines="Horizontal">

<AlternatingRowStyle BackColor="#F7F7F7" />

<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />

<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />


<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />

<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />

74 | P a g e
Ayush Dhumal
Roll No:10

<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />

<SortedAscendingCellStyle BackColor="#F4F4FD" />

<SortedAscendingHeaderStyle BackColor="#5A4C9D" />

<SortedDescendingCellStyle BackColor="#D8D8F0" />

<SortedDescendingHeaderStyle BackColor="#3E3277" />

</asp:GridView>

</div>

</form>

</body>

</html>

Default.aspx.cs
using System;

using System.Collections.Generic;

using System.Linq; using

System.Web; using System.Web.UI;

using System.Web.UI.WebControls;

using System.Configuration;

using System.Data;

using System.Data.SqlClient;

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

protected void Page_Load(object sender, EventArgs e)

75 | P a g e
Ayush Dhumal
Roll No:10

protected void Button1_Click(object sender, EventArgs e)

string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

SqlConnection con = new SqlConnection(conn);

SqlCommand cmd = new SqlCommand("Select * from cust", con);

SqlDataAdapter sda = new SqlDataAdapter();

DataSet ds = new DataSet();

sda.SelectCommand = cmd; sda.Fill(ds,

"CustomerCopy");

GridView1.DataSource = ds.Tables[0];

GridView1.DataBind();

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="false" targetFramework="4.0" />

76 | P a g e
Ayush Dhumal
Roll No:10

</system.web>

<connectionStrings>

<add name="conn" connectionString="Data


Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\admin\Documents\Visual Studio
2010\WebSites\7C\App_Data\Database.mdf;Integrated Security=True;User Instance=True"/>

</connectionStrings>

</configuration>

OUTPUT:

77 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 7B
Aim: Web Application to display data using Disconnected Data Access and
Data Binding using FormView control Source Code:

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-


transitional.dtd">

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">

<EditItemTemplate>

id:

<asp:TextBox ID="idTextBox" runat="server" Text='<%# Bind("id") %>' />

<br />

name:

<asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' />

<br />
mobile_no:

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

78 | P a g e
Ayush Dhumal
Roll No:10

Text='<%# Bind("mobile_no") %>' />

<br />

city:

<asp:TextBox ID="cityTextBox" runat="server" Text='<%# Bind("city") %>' />

<br />

state:

<asp:TextBox ID="stateTextBox" runat="server" Text='<%# Bind("state") %>' />

<br />

country:

<asp:TextBox ID="countryTextBox" runat="server" Text='<%# Bind("country") %>' />

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

id:

<asp:TextBox ID="idTextBox" runat="server" Text='<%# Bind("id") %>' />

<br />

name:

<asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' />

<br />

mobile_no:

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

Text='<%# Bind("mobile_no") %>' />


<br />

city:

79 | P a g e
Ayush Dhumal
Roll No:10

<asp:TextBox ID="cityTextBox" runat="server" Text='<%# Bind("city") %>' />

<br />

state:

<asp:TextBox ID="stateTextBox" runat="server" Text='<%# Bind("state") %>' />

<br />

country:

<asp:TextBox ID="countryTextBox" runat="server" Text='<%# Bind("country") %>' />

<br />

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

<asp:Label ID="idLabel" runat="server" Text='<%# Bind("id") %>' />

<br />

name:

<asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name") %>' />

<br />

mobile_no:

<asp:Label ID="mobile_noLabel" runat="server" Text='<%# Bind("mobile_no") %>' />

<br />

city:

<asp:Label ID="cityLabel" runat="server" Text='<%# Bind("city") %>' />

<br />
state:

<asp:Label ID="stateLabel" runat="server" Text='<%# Bind("state") %>' />

80 | P a g e
Ayush Dhumal
Roll No:10

<br />

country:

<asp:Label ID="countryLabel" runat="server" Text='<%# Bind("country") %>' />

<br />

</ItemTemplate>

</asp:FormView>

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

ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

SelectCommand="SELECT * FROM [cust]"></asp:SqlDataSource>

</div>

</form>

</body>

</html>

Next->

81 | P a g e
Ayush Dhumal
Roll No:10

82 | P a g e
Ayush Dhumal
Roll No:10

83 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:-

84 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 7C
Aim: Web Application to display data using Disconnected Data Access and
Data Binding using DetailView control Source Code:

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!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" DataSourceID="SqlDataSource1">

<Fields>

<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" />

<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />

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

SortExpression="mobile_no" />

<asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />

<asp:BoundField DataField="state" HeaderText="state" SortExpression="state" />

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

SortExpression="country" />

85 | P a g e
Ayush Dhumal
Roll No:10

</Fields>

</asp:DetailsView>

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

ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

SelectCommand="SELECT * FROM [cust]"></asp:SqlDataSource>

</div>

</form>

</body>

</html>

86 | P a g e
Ayush Dhumal
Roll No:10

87 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:-

88 | P a g e
Ayush Dhumal
Roll No:10

Practical No: 8A
Aim: Create a web application to demonstrate from security and windows security
with proper authentication and authorization properties.

Source Code:

Default1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default1" %>

<!DOCTYPE html>

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

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

<asp:CheckBox ID="CheckBox1" runat="server" Text="check thios if itr your personal computer"/><br /><br />

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

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

</div>

</form>

</body>

89 | P a g e
Ayush Dhumal
Roll No:10

</html>

Default1.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.Web.Security; public partial class

Default1 : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

protected bool authenticate(String uname, String pass)

if(uname == "Sanket")

{
if (pass == "123")
return true;

if (uname == "Lavesh")

{
if (pass == "456")
return true;

if (uname == "Ayush")

90 | P a g e
Ayush Dhumal
Roll No:10

if (pass == "789")
return true;

}
if (uname == "Shubham")

if (pass == "shu123")

return true;

}
if (uname == "Sanchin")

if (pass == "91123")

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

Label1.Text = "Invalid username or password...";

}
Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

91 | P a g e
Ayush Dhumal
Roll No:10

<!DOCTYPE html>

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

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

</div>

</form>

</body>

</html>

92 | P a g e
Ayush Dhumal
Roll No:10

Default2.aspx.cs
using System;

using

System.Collections.Generic;

using System.Linq; using

System.Web; using

System.Web.UI;

using System.Web.UI.WebControls;

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

protected void Page_Load(object sender, EventArgs e)

if (Session["username"] !=null)

Label1.Text = "Hello" + Session["username"].ToString();

93 | P a g e
Ayush Dhumal
Roll No:10

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

<httpRuntime targetFramework="4.5.2" />

<authentication mode="Forms">

<forms name="LoginPage" defaultUrl="Default1.aspx" protection="All" path="\">

</forms>

</authentication>

<authorization>

<allow users="?"/>

<deny users="?"/>

</authorization>

</system.web>

</configuration>

94 | P a g e
Ayush Dhumal
Roll No:10

95 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:

Practical No: 8B
Aim: create a web application to demonstrate use of various Ajax Controls.

Source Code:

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

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<!DOCTYPE html>

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:TextBox ID="TextBox1" runat="server" Height="273px" Width="692px"></asp:TextBox>

96 | P a g e
Ayush Dhumal
Roll No:10

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

<ajaxToolkit:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" EnableSanitization="False"


TargetControlID="Textbox1"></ajaxToolkit:HtmlEditorExtender>

</div>

</form>

</body>

</html>

OUTPUT:

97 | P a g e
Ayush Dhumal
Roll No:10

Practical No : 9
Aim: Program to create and use DLL.

Steps:

In Visual Studio -> file -> new -> Project -> select Class Library

Source Code:

ClassLibrary2.Class1
using System; using

System.Collections.Generic; using

System.Linq; using System.Text;

namespace ClassLibrary2

public class Class1

98 | P a g e
Ayush Dhumal
Roll No:10

public string UpperConvert(string text)

return text.ToUpper();

public string LowerConvert(string text)

return text.ToLower();

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

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

<div>

<asp:Button ID="Button1" runat="server" Text="Upper" onclick="Button1_Click" /> &nbsp;


&nbsp;

<asp:Button ID="Button2" runat="server" Text="Lower" onclick="Button2_Click" /><br /><br


/>

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

99 | P a g e
Ayush Dhumal
Roll No:10

</div>

</form>

</body>

</html>

Right Click on your website -> Add Reference Then browse to


the ClassLibrary1.dll file you created. Default.aspx.cs
using System.Web.UI; using

System.Web.UI.WebControls; using ClassLibrary2;

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

Class1 t = new Class1();

TextBox1.Text = t.UpperConvert(TextBox1.Text);

protected void Button2_Click(object sender, EventArgs e)

Class1 t = new Class1();

100 | P a g e
Ayush Dhumal
Roll No:10

TextBox1.Text = t.LowerConvert(TextBox1.Text);

101 | P a g e
Ayush Dhumal
Roll No:10

OUTPUT:

102 | P a g e
Ayush Dhumal
Roll No:10

Practical No : 10
Aim: Create a web application for User defined exception handling.

Source Code:

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

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


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

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

<head runat="server">

<title></title>

</head>

<body>

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

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

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

/><br />

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

/><br /><br />

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

</div>

</form>

</body>

</html>

103 | P a g e
Ayush Dhumal
Roll No:10

Default.aspx.cs
using System; using

System.Collections.Generic; using

System.Linq; using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

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

protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)

try

decimal a, b, result; a =

Decimal.Parse(TextBox1.Text); b =

Decimal.Parse(TextBox2.Text);

result = a / b;

Label1.Text = result.ToString();

Label1.ForeColor = System.Drawing.Color.Black;

catch (Exception err)

104 | P a g e
Ayush Dhumal
Roll No:10

Label1.Text = "Message : Wrong input" + err.Message;

Label1.Text += "<br/>";

Label1.Text += "Source" + err.Source;

Label1.Text += "<br/>";

Label1.Text += "Stack Trace" + err.StackTrace;

Label1.ForeColor = System.Drawing.Color.Red;

OUTPUT:

105 | P a g e
Ayush Dhumal
Roll No:10

106 | P a g e

You might also like