Advanced Web Programming Guide
Advanced Web Programming Guide
CERTIFICATE
Place:
Sanpada
Date: 07/10/21
____________________ _____________________
Sign of Subject In-charge Sign of External Examiner
__________________ _____________________
Sign of H.O.D Sign of Principal
INDEX
Sr.N Practicals Date Sign
o
1. Working with basic C# and ASP .NET
a. Create an application that obtains four int values from the user and 29/06/2021
displays the product.
b. Create an application to demonstrate string operations. 29/06/2021
c. Create an application that receives the (Student Id, Student Name, 29/06/2021
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.
d. Create an application to demonstrate following operations 29/06/2021
i. Generate Fibonacci series. ii. Test for prime numbers.
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
a. Create simple application to perform following operations 06/07/2021
i. Finding factorial Value ii.
Money Conversion iii. Quadratic Equation
iv. Temperature Conversion
b. Create simple application to demonstrate use of 06/07/2021
following concepts i. Function Overloading ii.
Inheritance (all types) iii. Constructor
overloading iv. Interfaces
c. Create simple application to demonstrate use of 06/07/2021
following concepts i. Using Delegates and
events ii. Exception handling
3. Working with Web Forms and Controls
a. Create a simple web page with various sever controls to demonstrate 13/07/2021
setting and use of their properties. (Example : AutoPostBack)
b. Demonstrate the use of Calendar control to perform following 13/07/2021
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
c. Demonstrate the use of Treeview control perform following 13/07/2021
operations.
a) Treeview control and datalist b) Treeview
operations
AIM: Create an application that obtains four int values from the user
and displays the product.
Design:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="multiplicationprogram.aspx.cs"
Inherits="practical1a.multiplicationprogram" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 172px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td class="auto-style2">Multiplication program</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">enter first number </td>
<td>
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">enter second number</td>
<td>
<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">enter third number</td>
<td>
<asp:TextBox ID="TextBox3"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">enter forth number</td>
<td>
<asp:TextBox ID="TextBox4"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Submit" />
</td>
<td> </td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
C# CODE:
product.aspx.cs:
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical1a
{
public partial class multiplicationprogram : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
OUTPUT:
PRACTICAL 1(B)
AIM: Create an application to demonstrate string operations.
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical1b.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td>String Operation</td>
</tr>
<tr>
<td>Enter String
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Submit" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label8"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label9"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label10"
runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
C# CODE:
string.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical1b
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
PRACTICAL 1(C):
AIM: 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.
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm.aspx.cs" Inherits="practical1c.WebForm" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 151px;
}
.auto-style3 {
width: 151px;
height: 23px;
}
.auto-style4 {
height: 23px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">Personal
Application</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">Student Id</td>
<td>
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Student Name</td>
<td>
<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Course Name</td>
<td>
<asp:TextBox ID="TextBox3"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Date of Birth</td>
<td>
<asp:Calendar ID="Calendar1"
runat="server"></asp:Calendar>
</td>
</tr>
<tr>
<td class="auto-style2">Mobile Number</td>
<td>
<asp:TextBox ID="TextBox4"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style3">
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Show" />
</td>
<td class="auto-style4">
<asp:Button ID="Button2" runat="server"
OnClick="Button2_Click" Text="Reset" />
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label3"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label4"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label5"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
C# CODE
Studinfo.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical1c
{
public partial class WebForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox4.Text = "";
}
}
}
OUTPUT:
PRACTICAL 1(D)
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Web.aspx.cs"
Inherits="practical1d.Web" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 124px;
}
.auto-style3 {
width: 152px;
}
.auto-style4 {
width: 194px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2"> </td>
<td class="auto-style3"> </td>
<td class="auto-style4"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">Enter Number</td>
<td class="auto-style3">
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
<td class="auto-style4">
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Fibonacci series" Width="190px" />
</td>
<td>
<asp:Label ID="Label1" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Number</td>
<td class="auto-style3">
<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
</td>
<td class="auto-style4">
<asp:Button ID="Button2" runat="server"
OnClick="Button2_Click" Text="Check Prime Number" Width="191px" />
</td>
<td>
<asp:Label ID="Label2" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2">Enter Number</td>
<td class="auto-style3">
<asp:TextBox ID="TextBox3"
runat="server"></asp:TextBox>
</td>
<td class="auto-style4">
<asp:Button ID="Button3" runat="server"
OnClick="Button3_Click" Text="Reverse Number" Width="194px" />
</td>
<td>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical1d
{
public partial class Web : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label6.Text = "";
string[] ColorName = new string[] { "Red", "Yellow", "Green", "Black",
"Pink" };
foreach (string ColorNames in ColorName)
{
Label6.Text = Label6.Text + " " + ColorNames.ToString();
}
}
}
OUTPUT:
PRACTICAL 2(A)
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical2a_i.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 130px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td class="auto-style2">Enter Number :</td>
<td>
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Button ID="Button1" runat="server"
Height="26px" OnClick="Button1_Click" Text="Factorial" Width="94px"
/>
</td>
<td> </td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server"
Text="Label"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical2a_i
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical2a_ii.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 172px;
}
</style>
</head>
<body>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2a_ii
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical2.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 85px;
}
.auto-style3 {
width: 85px;
height: 19px;
}
.auto-style4 {
height: 19px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style3">Enter a</td>
<td class="auto-style4">
<asp:TextBox ID="txtBoxa" runat="server"
OnTextChanged="Page_Load"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter b</td>
<td>
<asp:TextBox ID="txtBoxb"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Enter c</td>
<td>
<asp:TextBox ID="txtBoxc"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Result" />
</td>
<td>
<asp:Button ID="Button2" runat="server"
Text="Reset" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label3"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2"> <asp:Label ID="Label1"
runat="server"></asp:Label>
<asp:Label ID="Label2"
runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical2
{
{
x = Math.Sqrt(det);
r1 = (-b + x) / (2 * a);
r2 = (-b - x) / (2 * a);
Label3.Text = "There are two roots:";
Label1.Text = r1.ToString();
Label2.Text = r2.ToString();
}
else if (det == 0)
{
x = Math.Sqrt(det);
r1 = (-b + x) / (2 * a);
Label1.Text = "There is only one root:";
Label2.Text = r1.ToString();
}
else
{
Label1.Text = "There is no root!!!";
}
}
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical2a.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style3 {
width: 535px;
}
.auto-style4 {
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td class="auto-style4"
colspan="2"> Temperature Conversion</td>
</tr>
<tr>
<td class="auto-style3">Enter Value Celsius :
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Height="26px"
OnClick="Button1_Click" Text="Celsius to Fahrenheit" Width="200px"
/>
</td>
<td>
<asp:Label ID="Label1" runat="server"
Text="Label℉"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style3">Enter Value Fahrenheit :
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Height="27px"
OnClick="Button2_Click" Text="Fahrenheit to Celsius" Width="199px"
/>
</td>
<td>
<asp:Label ID="Label2" runat="server"
OnDataBinding="Button2_Click" Text="Lable℃"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical2a
{
public partial class WebForm1 : System.Web.UI.Page
{
public class tempConv
{
public double ctof(double temp)
{
temp = 9.0 / 5.0 * temp + 32;
return temp;
}
public double ftoc(double temp)
{
temp = (temp - 32) * 5 / 9;
return temp;
}
}
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
PRACTICAL 2(B):
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical2b_i.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 279px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">Function
Overloading</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label3"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2b_i
{
public partial class WebForm1 : System.Web.UI.Page
{
public int add(int a)
{
return a + a;
}
public int add(int a, int b)
{
return a + b;
}
public int add(int a,int b,int c)
{
return a + b + c;
}
protected void Page_Load(object sender, EventArgs e)
{
int x, y, z;
x = add(2);
y = add(2, 3);
z = add(2, 3, 4);
Label1.Text = x.ToString();
Label2.Text = y.ToString();
Label3.Text = z.ToString();
}
}
}
OUTPUT:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="SingleInheritance.aspx.cs"
Inherits="Practical2b_ii_1.SingleInheritance" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td>Enter Number :
<asp:TextBox ID="TextBox1" runat="server"
Height="21px" Width="195px"></asp:TextBox>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Result" />
</td>
</tr>
<tr>
<td>Square of a number : <asp:Label ID="Label1"
runat="server"></asp:Label>
<br />
Cube of a number :
<asp:Label ID="Label2"
runat="server"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2b_ii_1
{
public partial class SingleInheritance : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
OUTPUT:
2. Multilevel Inheritance:
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Multilevel_Inheritance.aspx.cs"
Inherits="practical2b_ii_2.Multilevel_Inheritance" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td>Enter Number :
<asp:TextBox ID="TextBox1" runat="server"
Height="21px" Width="174px"></asp:TextBox>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Result" />
</td>
</tr>
<tr>
<td>Number is power of 2 : <asp:Label
ID="Label1" runat="server"></asp:Label>
<br />
Number is power of 3 :
<asp:Label ID="Label2"
runat="server"></asp:Label>
<br />
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical2b_ii_2
{
public partial class Multilevel_Inheritance : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
public class A
{
public int pow2(int Val1)
{
return Val1 * Val1;
}
}
public class B : A
{
public int pow3(int Val1)
{
int v1 = pow2(Val1);
return v1 * Val1;
}
}
public class C:B
{
public int pow4(int Val1)
{
int v1 = pow3(Val1);
return v1 * Val1;
}
}
}
OUTPUT:
3. Hierarchical Inheritance:
DESIGN:
HTML CODE:
<%@ Page Language="C#"
AutoEventWireup="true"
CodeBehind="Hierarchical_Inheri
tance.aspx.cs"
Inherits="Practical2b_ii_3.Hier
archical_Inheritance" %>
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/x
html">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td>Enter a :
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Enter b :
<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Result" />
</td>
</tr>
<tr>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2b_ii_3
{
public class A
{
public int a;
public int b;
}
public class B:A
{
public int add(int Val1, int Val2)
{
a = Val1;
b = Val2;
return a + b;
}
}
public class C:A
{
public int sub(int Val1, int Val2)
{
a = Val1;
b = Val2;
return a - b;
}
}
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical2b_iii.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td>Constructor Overloading :</td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="Label2"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="Label3"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical2b_iii
{
OUTPUT:
iv. Interfaces:
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical2iv.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td>Area of a Circle and Rectangle using
Interface</td>
</tr>
<tr>
<td>Area of
Circle :
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>Area of Rectangle: <asp:Label
ID="Label2" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
<p>
</p>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical2iv
{
interface Area
{
double show(double s, double t);
}
class Rect : Area
{
public double show(double s, double t)
{
return s * t;
}
}
class Circle : Area
{
public double show(double s, double t)
{
return (3.14 * s * s);
}
}
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Rect r1 = new Rect();
double x = r1.show(3, 4);
Circle c1 = new Circle();
double y = c1.show(3, 4);
Label1.Text = x.ToString();
Label2.Text = y.ToString();
}
}
}
OUTPUT:
PRACTICAL 2(C):
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical2Ci.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td>
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2"
runat="server"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2Ci
{
public partial class WebForm1 : System.Web.UI.Page
{
public delegate string dele();
public static string display1()
{
string s1 = "Shaikh Mariyam";
return s1;
}
public static string display2()
{
string s2 = "Mariyam Hisam Shaikh";
return s2;
}
protected void Page_Load(object sender, EventArgs e)
{
dele d1 = new dele(display1);
d1();
dele d2 = new dele(display2);
d2();
Label1.Text = d1();
Label2.Text = d2();
}
}
}
OUTPUT:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical2Cii.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style5 {
width: 1666px;
}
.auto-style6 {
width: 92%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td colspan="2">Division of Two Numbers</td>
</tr>
<tr>
<td class="auto-style5">Num1 :
<br />
</td>
<td class="auto-style6">
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style5">
<asp:Button ID="Button1" runat="server"
Height="25px" OnClick="Button1_Click" Text="Result" Width="79px" />
<br />
</td>
<td class="auto-style6"> </td>
</tr>
<tr>
<td class="auto-style5">
<asp:Label ID="Label1"
runat="server"></asp:Label>
<br />
</td>
<td class="auto-style6"> </td>
</tr>
</table>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical2Cii
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
{
try
{
int a = int.Parse(TextBox1.Text);
int[] b = { 12, 23, 33 };
int resultVal;
resultVal = (b[3] / a);
Label1.Text="The result is:" + resultVal.ToString();
}
catch(System.DivideByZeroException ex)
{
Label1.Text = ex.ToString();
}
catch(System.IndexOutOfRangeException ex)
{
Label1.Text = ex.ToString();
}
}
}
}
OUTPUT:
PRACTICAL 3(A):
AIM: Create a simple web page with various sever controls to demonstrate
setting and use of their properties. (Example : AutoPostBack)
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical3a.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Name: <asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox></p>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical3a
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
OUTPUT:
PRACTICAL 3(B):
HTML CODE:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:Calendar ID="Calendar1" runat="server"
BackColor="White" BorderColor="Black" BorderStyle="Solid"
CellSpacing="1" Font-Names="Verdana" Font-Size="9pt"
ForeColor="Black" Height="250px" NextPrevFormat="ShortMonth"
OnDayRender="Calendar1_DayRender" ShowGridLines="True"
Width="330px">
<DayHeaderStyle Font-Bold="True" Font-Size="8pt"
ForeColor="#333333" Height="8pt" />
<DayStyle BackColor="#CCCCCC" />
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication4
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Calendar1.SelectedDates.SelectRange(Calendar1.SelectedDate,
Calendar1.SelectedDate.AddDays(10));
Label lbl1 = new Label();
lbl1.Text = "<br>Ganpati!";
e.Cell.Controls.Add(lbl1);
}
}
OUTPUT:
PRACTICAL 3(C):
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical3ca.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Treeview Control Navigation:<br />
<asp:TreeView ID="TreeView1" runat="server"
ImageSet="Arrows">
<HoverNodeStyle Font-Underline="True"
ForeColor="#5555DD" />
<Nodes>
<asp:TreeNode Text="ASP.NET Practs"
Value="ASP.NET Practs">
<asp:TreeNode Text="Calender Control"
Value="RED"></asp:TreeNode>
<asp:TreeNode Text="Constructor Overloading"
Value="GREEN"></asp:TreeNode>
<asp:TreeNode Text="Inheritance"
Value="BLUE"></asp:TreeNode>
<asp:TreeNode 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:<br />
<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") %> <br />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
C# CODE:
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;
namespace practical3ca
{
public partial class WebForm1 : 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();
}
}
}
XML FILE:
<?xml version="1.0" encoding="utf-8" ?>
<studentdetail>
<student>
<sid>1</sid>
<sname>Mariyam</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>2</sid>
<sname>Anam</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>3</sid>
<sname>Fatima</sname>
<sclass>TYCS</sclass>
</student>
<student>
<sid>4</sid>
<sname>Afreen</sname>
<sclass>TYCS</sclass>
</student>
</studentdetail>
OUTPUT:
PRACTICAL 4(A):
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical4a.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script runat="server">
void ValidateBtn_OnClick(Object sender,EventArgs e)
{
if(Page.IsValid)
{
lbl1.Text = "Thank You!";
}
else
{
<!--
For more information on how to configure your ASP.NET application,
please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode"
value="None"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeP
rovider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6
/nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript"
extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvi
der, Microsoft.CodeDom.Providers.DotNetCompilerPlatform,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14
/nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
OUTPUT:
PRACTICAL 4(B):
AIM: Create Web Form to demonstrate use of Adrotator Control.
Add a XML file, name it "adds.xml"
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="Practical4b.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:AdRotator ID="AdRotator1" runat="server"
DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/adds.xml"></asp:XmlDataSource>
</div>
</form>
</body>
</html>
XML FILE:
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>ROSE.jpg</ImageUrl>
<NavigateUrl></NavigateUrl>
<AlternateText>flower</AlternateText>
<Impressions>20</Impressions>
<Keyword>flowers</Keyword>
</Ad>
<Ad>
<ImageUrl>sunflower.jpg</ImageUrl>
<NavigateUrl></NavigateUrl>
<AlternateText>flower</AlternateText>
<Impressions>20</Impressions>
<Keyword>flower</Keyword>
</Ad>
<Ad>
<ImageUrl>orchids.jpg</ImageUrl>
<NavigateUrl></NavigateUrl>
<AlternateText>flower</AlternateText>
<Impressions>20</Impressions>
<Keyword>flower</Keyword>
</Ad>
</Advertisements>
OUTPUT:
PRACTICAL 4(C):
Website -> Add -> Web User Control and Name it ‘MyUserControl’
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="MyUserControl.aspx.cs"
Inherits="practical4c.MyUserControl1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
MyUserControl.ascx:
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="MyUserControl.ascx.cs" Inherits="practical4c.MyUserControl" %>
<h3>This is User Contro1 </h3>
<table>
<tr>
<td>Name</td>
<td>
<td>
<asp:Button ID="txtSave" runat="server" Text="Save"
onclick="txtSave_Click" />
</td>
</tr>
</table><br />
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical4c
{
public partial class MyUserControl1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
. PRACTICAL 5(A):
AIM: Create Web Form to demonstrate use of Website Navigation controls and
Site Map.
Add Site Map File
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="default1.aspx.cs" Inherits="practica5a.default1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
</div>
</form>
</body>
</html>
C# CODE:
Web.sitemap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-
1.0" >
<siteMapNode url="practical5a.aspx" title="Home"
description="Home page of our website">
<siteMapNode url="default1.aspx" title="Page2"
description="Page2" />
<siteMapNode url="default2.aspx" title="Page3"
description="Page3" />
<siteMapNode url="default3.aspx" title="Page4"
description="Page4" />
</siteMapNode>
</siteMap>
OUTPUT:
PRACTICAL 5(B):
DESIGN:
SkinFile1.skin:
<asp:Lable runat="server" ForeColor="red" Font-Size="14pt" Font-
Name="Verdana" />
<asp:Button runat="server" BorderStyle="solod"
Boederwidth="2px" Bordercolor="Blue"
Backcolor="Magenta" />
HTML CODE:
Demostyle.css:
body {
background-color:yellow;
font-family:Cambria;
font-size:18px;
}
MasterPage.master:
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<link href="css/my.css" rel="demostyle.css" type="text/css"/>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1"
runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Demo.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master"
AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical5B.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head"
runat="server">
</asp:Content>
<asp:Content ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Advance Web
Programming "></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Enterprise
Java"></asp:Label>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Lable"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Demo"
OnClick="Button1_Click" />
<br />
<br />
<br />
</asp:Content>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical5B
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
PRACTICAL 5(C):
1. View State
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="ViewState.aspx.cs" Inherits="practical5c.ViewState" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
ViewState Data:<asp:Label ID="lblStr"
runat="server"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" style="height: 26px" Text="Get Data" />
</div>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical5c
{
public partial class ViewState : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
string str = "Mariyam Shaikh";
if (ViewState["name"] == null) ;
{
ViewState["name"] = str;
}
}
}
}
}
}
OUTPUT:
2. Query String
DESIGN:
HTML CODE:
QueryString.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="QueryString.aspx.cs" Inherits="practical5c.QueryString"
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Query String :<br />
UserId:
<asp:TextBox ID="txtUserId"
runat="server"></asp:TextBox>
<br />
UserName:
<asp:TextBox ID="txtUserName"
runat="server"></asp:TextBox>
<br />
QS.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
QueryString Parameters Values In QueryString.aspx
Page<br />
<br />
UserId:<asp:Label ID="lblUserId"
runat="server"></asp:Label>
<br />
<br />
UserName:<asp:Label ID="lblUserName"
runat="server"></asp:Label>
</div>
</form>
</body>
</html>
C# CODE:
QueryString.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical5c
{
public partial class QueryString : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
QS.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical5c
{
public partial class QS : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
lblUserId.Text = Request.QueryString["UserId"];
lblUserName.Text = Request.QueryString["UserName"];
}
}
}
}
OUTPUT
3. Cookies
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="cookie.aspx.cs" Inherits="practical5c.cookie" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body id="BodyTag" runat="server">
<form id="form1" runat="server">
<div>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace practical5c
{
public partial class cookie : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(Request.Cookies["BackgroundColor"]!=null)
{
ColorSelector.SelectedValue =
Request.Cookies["BackgroundColor"].Value;
BodyTag.Style["background-color"] =
ColorSelector.SelectedValue;
}
}
cookie.Expires = DateTime.Now.AddMilliseconds(20);
Response.SetCookie(cookie);
}
}
}
OUTPUT:
HTML CODE:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="P5c.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Visitor Count:<% =Application["OnlineUsers"].ToString()
%>
</div>
</form>
</body>
</html>
C# CODE:
Global.asax
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
Application["OnlineUsers"] = 0;
}
void Application_End(object sender, EventArgs e)
{
}
void Application_Error(object sender, EventArgs e)
{
}
void Session_start(object sender, EventArgs e)
{
Application.Lock();
Application["OnlineUsers"] = (int)Application["OnlineUsers"]
+ 1;
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application["OnlineUsers"] = (int)Application["OnlineUsers"]
- 1;
Application.UnLock();
}
</script>
OUTPUT:
PRACTICAL 6(A):
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="default.aspx.cs" Inherits="Practical6a._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:TextBox ID="TextBox1" runat="server" Height="84px"
TextMode="MultiLine" Width="578px"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Execute Query" />
<br />
<br />
<asp:TextBox ID="TextBox2" runat="server" Height="236px"
TextMode="MultiLine" Width="587px"></asp:TextBox>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1"
runat="server"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Web.config:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application,
please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<connectionStrings>
<add name="connStr" connectionString="Data
Source=DESKTOP123\TEW_SQLEXPRESS;Initial Catalog=Customer;Integrated
Security=True;Pooling=False" />
</connectionStrings>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeP
rovider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:6
/nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript"
extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvi
der, Microsoft.CodeDom.Providers.DotNetCompilerPlatform,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:14
/nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
</configuration>
C# CODE:
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;
namespace Practical6a
{
public partial class _default : System.Web.UI.Page
{
TextBox2.Text = "";
while (reader.Read())
{
//To add new blank line in the text area
TextBox2.Text += Environment.NewLine;
OUTPUT:
PRACTICAL 6(B):
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="default2.aspx.cs" Inherits="Practical6a.default2" %>
<!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="Cutomer
Details :"></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server"></asp:Label>
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Display Records" />
</div>
</form>
</body>
</html>
C# CODE:
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;
namespace Practical6b
{
public partial class default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("Select FirstName,
LastName, Country from Customer", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
Label2.Text += reader["FirstName"].ToString( ) + "
" + reader["LastName"].ToString( ) + "Country:" +
reader["Country"].ToString( ) + "<br";
}
reader.Close();
con.Close();
}
}
}
OUTPUT:
PRACTICAL 6(C):
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="default3.aspx.cs" Inherits="Practical6a.default3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 808px;
height: 846px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="auto-style1">
OUTPUT:
PRACTICAL 7(A):
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="default5.aspx.cs" Inherits="Practical6a.default5" %>
<!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"
DataSourceID="SqlDataSource1" DataTextField="Country"
DataValueField="Country">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CustomerConnectionString %>"
SelectCommand="SELECT [Country] FROM
[Customer]"></asp:SqlDataSource>
<br />
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Click Me !" />
&n
bsp;
<asp:Label ID="Label1" runat="server" Text="The Country
You Have Selected Is :"></asp:Label>
</div>
</form>
</body>
</html>
C# CODE:
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;
namespace Practical7a
{
public partial class default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("Select Distinct
Country from Customer", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataTextField = "Country";
DropDownList1.DataBind();
reader.Close();
con.Close();
}
Label1.Text = "The Country You Have Selected Is :" +
DropDownList1.SelectedValue;
}
}
}
OUTPUT:
PRACTICAL 7(B):
AIM: Create a web application for to display the phone no of an author using
database
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="PhoneNo.aspx.cs" Inherits="Practical6a.PhoneNo" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
Select Your Name To Get Phone Number:<br />
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Get Phone No." />
<asp:Label ID="Label1" runat="server" Text="Your Phone
Number Is :"></asp:Label>
</form>
</body>
</html>
C# CODE:
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;
namespace Practical7b
{
public partial class PhoneNo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack==false)
{
string connStr=
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("Select Distinct
FirstName,LastName,Phone from Customer", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataTextField = "FirstName";
DropDownList1.DataValueField = "Phone";
DropDownList1.DataBind();
reader.Close();
con.Close();
}
}
OUTPUT:
PRACTICAL 7(C):
AIM: Create a web application for inserting and deleting record from a
database. (Using Execute-Non Query).
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical7c.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 128px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">AccountNumber:</td>
<td>
<asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">CustomerName:</td>
<td>
<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">BankBranchName:</td>
<td>
<asp:TextBox ID="TextBox3"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">State:</td>
<td>
<asp:TextBox ID="TextBox4"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Zipcode:</td>
<td>
<asp:TextBox ID="TextBox5"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Insert" />
</td>
<td>
<asp:Button ID="Button2" runat="server"
OnClick="Button2_Click" style="height: 26px" Text="Delete" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
namespace practical7c
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
OUTPUT:
PRACTICAL 8(A):
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm2.aspx.cs" Inherits="Practical6a.WebForm2" %>
<!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"
DataSourceID="SqlDataSource1" DataTextField="ProductName"
DataValueField="Id"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CustomerConnectionString %>"
SelectCommand="SELECT [Id], [ProductName], [SupplierId],
C# CODE:
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;
namespace Practical6a
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT:
PRACTICAL 8(B):
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="practical8b.aspx.cs" Inherits="Practical6a.practical8b"
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False" DataKeyNames="Id"
DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="Id" HeaderText="Id"
ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="FirstName"
HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName"
HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="City" HeaderText="City"
SortExpression="City" />
<asp:BoundField DataField="Country"
HeaderText="Country" SortExpression="Country" />
<asp:BoundField DataField="Phone" HeaderText="Phone"
SortExpression="Phone" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CustomerConnectionString %>"
SelectCommand="SELECT [Id], [FirstName], [LastName], [City],
[Country], [Phone] FROM [Customer]"></asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server"
BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px" CellPadding="4" CellSpacing="2" DataKeyNames="Id"
DataSourceID="SqlDataSource2" ForeColor="Black" GridLines="Both">
<EditItemTemplate>
Id:
<asp:Label ID="IdLabel1" runat="server" Text='<%#
Eval("Id") %>' />
<br />
ProductName:
<asp:TextBox ID="ProductNameTextBox" runat="server"
Text='<%# Bind("ProductName") %>' />
<br />
SupplierId:
<asp:TextBox ID="SupplierIdTextBox" runat="server"
Text='<%# Bind("SupplierId") %>' />
<br />
UnitPrice:
<asp:TextBox ID="UnitPriceTextBox" runat="server"
Text='<%# Bind("UnitPrice") %>' />
<br />
Package:
<asp:TextBox ID="PackageTextBox" runat="server"
Text='<%# Bind("Package") %>' />
<br />
IsDiscontinued:
<asp:CheckBox ID="IsDiscontinuedCheckBox"
runat="server" Checked='<%# Bind("IsDiscontinued") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" />
</EditItemTemplate>
<EditRowStyle BackColor="#000099" Font-Bold="True"
ForeColor="White" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True"
ForeColor="White" />
<InsertItemTemplate>
Id:
<asp:TextBox ID="IdTextBox" runat="server" Text='<%#
Bind("Id") %>' />
<br />
ProductName:
<asp:TextBox ID="ProductNameTextBox" runat="server"
Text='<%# Bind("ProductName") %>' />
<br />
SupplierId:
<asp:TextBox ID="SupplierIdTextBox" runat="server"
Text='<%# Bind("SupplierId") %>' />
<br />
UnitPrice:
<asp:TextBox ID="UnitPriceTextBox" runat="server"
Text='<%# Bind("UnitPrice") %>' />
<br />
Package:
<asp:TextBox ID="PackageTextBox" runat="server"
Text='<%# Bind("Package") %>' />
<br />
IsDiscontinued:
<asp:CheckBox ID="IsDiscontinuedCheckBox"
runat="server" Checked='<%# Bind("IsDiscontinued") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
Id:
<asp:Label ID="IdLabel" runat="server" Text='<%#
Eval("Id") %>' />
<br />
ProductName:
<asp:Label ID="ProductNameLabel" runat="server"
Text='<%# Bind("ProductName") %>' />
<br />
SupplierId:
<asp:Label ID="SupplierIdLabel" runat="server"
Text='<%# Bind("SupplierId") %>' />
<br />
UnitPrice:
<asp:Label ID="UnitPriceLabel" runat="server"
Text='<%# Bind("UnitPrice") %>' />
<br />
Package:
<asp:Label ID="PackageLabel" runat="server" Text='<
%# Bind("Package") %>' />
<br />
IsDiscontinued:
<asp:CheckBox ID="IsDiscontinuedCheckBox"
runat="server" Checked='<%# Bind("IsDiscontinued") %>'
Enabled="false" />
<br />
</ItemTemplate>
<PagerStyle BackColor="#CCCCCC" ForeColor="Black"
HorizontalAlign="Left" />
<RowStyle BackColor="White" />
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:CustomerConnectionString %>"
SelectCommand="SELECT [Id], [ProductName], [SupplierId],
[UnitPrice], [Package], [IsDiscontinued] FROM
[Product]"></asp:SqlDataSource>
</form>
</body>
</html>
OUTPUT:
PRACTICAL 8(C):
AIM: Create a web application to display Using Disconnected Data Access and
Databinding using GridView
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="disconnectedmodel.aspx.cs"
Inherits="Practical8c.disconnectedmodel" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
text-align: left;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="auto-style1">
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Show Disconnect Fetched Data" />
<br />
</div>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
namespace Practical8c
{
public partial class disconnectedmodel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
SqlDataAdapter objDa = new SqlDataAdapter();
DataSet objDs = new DataSet();
using (SqlConnection objConn = new
SqlConnection(connStr))
{
SqlCommand objCmd = new SqlCommand("Select * from
Customer", objConn);
objDa.SelectCommand = objCmd;
objDa.Fill(objDs, "Customer");
GridView1.DataSource = objDs.Tables[0];
GridView1.DataBind();
}
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from
Customer", conn);
DataSet dst = new DataSet();
da.Fill(dst);
GridView1.DataSource = dst;
GridView1.DataBind();
}
}
}
OUTPUT:
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical9.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:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" BackColor="White" BorderColor="#999999"
BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
DataKeyNames="Id" DataSourceID="SqlDataSource1" ForeColor="Black"
GridLines="Vertical">
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="Id"
DataTextField="Id" />
<asp:BoundField DataField="FirstName"
HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName"
HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="City"
HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Country"
HeaderText="Country" SortExpression="Country" />
<asp:BoundField DataField="Phone"
HeaderText="Phone" SortExpression="Phone" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-
Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="Gray" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Data Source=DESKTOP123\TEW_SQLEXPRESS;Initial
Catalog=Customer;Integrated Security=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [Id],
[FirstName], [LastName], [City], [Country], [Phone] FROM
[Customer]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
OUTPUT:
PRACTICAL 9(B):
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="gridview.aspx.cs" Inherits="practical9b.gridview" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="Id"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id"
ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="FirstName"
HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName"
HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="City"
HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Country"
HeaderText="Country" SortExpression="Country" />
<asp:BoundField DataField="Phone"
HeaderText="Phone" SortExpression="Phone" />
<asp:CommandField ButtonType="Button"
HeaderText="Edit" ShowEditButton="True" ShowHeader="True" />
<asp:CommandField ButtonType="Button"
HeaderText="Delete" ShowDeleteButton="True" ShowHeader="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Data Source=DESKTOP123\TEW_SQLEXPRESS;Initial
Catalog=Customer;Integrated Security=True" SelectCommand="SELECT *
FROM [Customer]" UpdateCommand="UPDATE Customer SET
FirstName=@FirstName,LastName=@LastName,City=@City,Country=@Country,
Phone=@phone Where Id=@Id">
<UpdateParameters>
<asp:Parameter Name="Id" Type="Int32" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
OUTPUT:
PRACTICAL 9(C):
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical9c.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:GridView ID="GridView1" runat="server"
BackColor="White" OnSorting="GridView1_Sorting"
BorderColor="#336666"
OnPageIndexChanged="GridView1_PageIndexChanging"
BorderStyle="Double" BorderWidth="3px" CellPadding="4"
GridLines="Horizontal" PageSize="5" style="z-index:1"
AllowSorting="true"
OnPageIndexChanging="GridView1_PageIndexChanging1"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" >
<FooterStyle BackColor="White" ForeColor="#333333"
/>
<HeaderStyle BackColor="#336666" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#336666" ForeColor="White"
HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#333333" />
<SelectedRowStyle BackColor="#339966" Font-
Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#487575" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#275353" />
</asp:GridView>
</div>
</form>
</body>
</html>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace Practical9c
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DemonstrateDataView();
}
}
private void DemonstrateDataView()
{
DataTable myTable = new DataTable("myTable");
DataColumn colItem1 = new DataColumn("Id",
Type.GetType("System.Int32"));
DataColumn colItem2 = new DataColumn("P_Name",
Type.GetType("System.String"));
DataColumn colItem3 = new DataColumn("Price",
Type.GetType("System.String"));
myTable.Columns.Add(colItem1);
myTable.Columns.Add(colItem2);
myTable.Columns.Add(colItem3);
DataRow NewRow;
for (int i = 0; i < 50; i++)
{
NewRow = myTable.NewRow();
NewRow["Id"] = i;
NewRow["P_Name"] = "Product" + i;
NewRow["Price"] = (20 * (i + 1));
myTable.Rows.Add(NewRow);
}
GridView1.DataSource = myTable;
GridView1.AllowPaging = true;
GridView1.AllowSorting = true;
ViewState["dataTable"] = myTable;
ViewState["sortdr"] = "Asc";
GridView1.DataBind();
}
if (dtrslt.Rows.Count > 0)
{
if (Convert.ToString(ViewState["sortdr"]) == "Asc")
{
dtrslt.DefaultView.Sort = e.SortExpression +
"Desc";
ViewState["sortdr"] = "Asc";
}
else
{
dtrslt.DefaultView.Sort = e.SortExpression +
"Asc";
ViewState["sortdr"] = "Asc";
}
GridView1.DataSource = dtrslt;
GridView1.DataBind();
}
}
GridView1.PageIndex = e.NewPageIndex;
DemonstrateDataView();
}
}
}
OUTPUT:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical10a.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
namespace Practical10a
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
writer.WriteEndDocument();
writer.Close();
Label1.Text = "Data Write Sucessfully";
}
OUTPUT:
PRACTICAL 10(B):
DESIGN:
HTML CODE:
Login.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Login.aspx.cs" Inherits="practical10b.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 188px;
}
.auto-style3 {
width: 188px;
height: 25px;
}
.auto-style4 {
height: 25px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">User Name:</td>
<td>
<asp:TextBox ID="txtuser" runat="server"
Enabled="False"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Password:</td>
<td>
<asp:TextBox ID="txtpwd"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Login" />
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style3">
<asp:CheckBox ID="chkrem" runat="server" />
Remember Me</td>
<td class="auto-style4"></td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label1"
runat="server"></asp:Label>
</td>
<td> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
Welcome.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Welcome.aspx.cs" Inherits="practical10b.Welcome" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
C# CODE:
Login.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;
namespace practical10b
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected bool authenticate(String uname, String pass)
{
if (uname == "Mariyam")
{
if (pass == "Mariyam24")
return true;
}
return false;
}
FormsAuthentication.RedirectFromLoginPage(txtuser.Text,
chkrem.Checked);
Session["Username"] = txtuser.Text;
Response.Redirect("Welcome.aspx");
else
{
Label1.Text = "Invalid user or password";
}
}
}
}
Welcome.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical10b
{
public partial class Welcome : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Username"] != null)
{
Label1.Text = Session["Username"].ToString();
}
}
}
}
OUTPUT:
PRACTICAL 10(C):
DESIGN:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="Practical10c.WebForm1" %>
<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>
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Columns="80"
Rows="20" TextMode="MultiLine"></asp:TextBox>
<ajaxToolkit:HtmlEditorExtender
ID="TextBox1_HtmlEditorExtender" runat="server"
EnableSanitization="false" BehaviorID="TextBox1_HtmlEditorExtender"
TargetControlID="TextBox1">
<Toolbar>
<ajaxToolkit:Bold />
<ajaxToolkit:Copy />
<ajaxToolkit:CreateLink />
<ajaxToolkit:Delete />
<ajaxToolkit:Cut />
</Toolbar>
</ajaxToolkit:HtmlEditorExtender>
</div>
</form>
</body>
</html>
OUTPUT:
HTML CODE:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_11.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:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="Upper" />
<asp:Button ID="Button2" runat="server"
OnClick="Button2_Click" Text="Lower" />
namespace Mariyam
{
public class Class1
{
public String UpperConvert(String text)
{
return text.ToUpper();
}
public String LowerConvert(String text)
{
return text.ToLower();
}
}
}
C# CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Mariyam;
namespace practical_11
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OUTPUT: