Awp Final Practical
Awp Final Practical
Practical
No.
Date Sign
Topic
1. Working with basic C# and ASP .NET
a. Create an application that obtains four int values
from the user and displays the product.
b. Create an application to demonstrate string
operations.
c. Create an application that receives the (Student Id,
Student Name, Course Name, Date of Birth)
information from a set of students. The application
should also display the information of all the students
once the data entered.
d. Create an application to demonstrate following
operations i. Generate Fibonacci series. ii. Test
for prime numbers. iii. Test for vowels.
iv. Use of foreach loop with arrays
AutoPostBack)
b. Demonstrate the use of Calendar control to perform
following operations.
4|Page
c. Demonstrate the use of Datalist link control.
7. Working with Database
a. Create a web application to display Databinding using
dropdownlist control.
b. Create a web application for to display the phone no of
an author using database.
c. Create a web application for inserting and deleting
record from a database. (Using Execute-Non Query).
Practical 1
Default .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs"
Inherits="Default3" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
6|Page
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:TextBox ID="TextBox1" runat="server" Height="23px"></asp:TextBox>
<p>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</p>
<p>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</p>
<p>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</p>
<p>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</p>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Button" />
</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;
7|Page
Convert.ToInt16(TextBox4.Text); int q
= x * y * z * p;
TextBox5.Text = Convert.ToString(q);
}
}
Output
Design
Default .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
8|Page
<!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>
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox2" runat="server" Height="92px"
TextMode="MultiLine"
Width="231px"></asp:TextBox>
<p>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Button" />
</p>
</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;
9|Page
str1 = TextBox1.Text;
string[] words = str1.Split(' ');
for(int i =0;i<words.Length;i++)
{
TextBox2.Text=TextBox2.Text + words[i]+"\r\n";
}
}
}
Output
c) Create an application that receives the (Student Id, Student Name, Course Name, Date of Birth)
information from a set of students. The application should also display the information of all the
students once the data entered. Design
10 | P a g e
Default .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs"
Inherits="Default4" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<p>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</p>
<p>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</p>
<p>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</p>
<p>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Button" />
11 | P a g e
</p>
<p>
<asp:Button ID="Button2" runat="server" onclick="Button2_Click"
Text="Button" />
</p>
</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;
struct student
{
public string studid, name, cname;
public string dob;
}
;
public partial class Default4 : System.Web.UI.Page
{
static student[] s = new student[5];
static int i;
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("i=" + i);
s[i].studid = TextBox1.Text;
s[i].name = TextBox2.Text;
s[i].cname = TextBox3.Text;
s[i].dob = TextBox4.Text; i++;
}
protected void Button2_Click(object sender, EventArgs e)
{
for (int y = 0; y < i; y++)
{
Response.Write("i=" + y);
12 | P a g e
Response.Write("student id:" + s[y].studid + "<br>");
Response.Write("Name:" + s[y].cname + "<br>");
Response.Write("Date Of Birth :" + s[y].dob + "<br>");
Response.Write("class:" + s[y].cname + "<br>");
}
}
}
Output
13 | P a g e
Default .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default7.aspx.cs"
Inherits="Default7" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click1" />
<p>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p>
</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;
14 | P a g e
public partial class Default7 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
int f1 = 0, f2 = 1, f3, n, co;
n = int.Parse(TextBox1.Text); co
= 0;
Response.Write("Fibonaaci series :");
Response.Write(f1 + "\t" + f2); while
(co <= n)
{
f3 = f1 + f2;
Response.Write("\t" + f3);
f1 = f2;
Response.Write("\t" + f3);
f1 = f2; f2 = f3;
co++;
}
}
}
Output
15 | P a g e
Test For Prime Number
Design
Default .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<br />
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Button" />
<p>
</p>
<p>
</p>
<div>
<br />
16 | P a g e
</div>
</form>
<p>
</p>
</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;
else if (c < n - 1)
Response.Write(n + "is not prime number");
else
Response.Write(n + "is prime number");
}
}
17 | P a g e
Output
Default .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
18 | P a g e
<!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>
</div>
<p>
</p>
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</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;
19 | P a g e
if ((ch.Substring(i, 1) == "a") || (ch.Substring(i, 1) == "e") ||
(ch.Substring(i, 1) == "i") || (ch.Substring(i, 1) == "o") ||
(ch.Substring(i, 1) == "u"))
{
count++;
}
}
Response.Write("Given string:" + ch);
Response.Write("Total number of vowels:" + count);
}
}
Output
Design
20 | P a g e
Default .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</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;
21 | P a g e
}
}
Output
Design
Default .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
22 | P a g e
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</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;
23 | P a g e
}
Output
24 | P a g e
Practical 2
Design
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
25 | P a g e
</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;
class fact { public int n, f;
public fact() { f = 1;
}
public void cal()
{
int i;
for (i = 1; i <= n; i++)
{
f = f * i;
}
} }
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
fact f1 = new fact();
f1.n = 5; f1.cal();
Response.Write(f1.n + "!= " + f1.f);
}
}
Output
ii)Money Conversion
Design
26 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
oncheckedchanged="RadioButton1_CheckedChanged" Text="Dollar to Rupee" />
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True"
oncheckedchanged="RadioButton2_CheckedChanged" Text="Rupee to Dollar" />
<asp:RadioButton ID="RadioButton3" runat="server" AutoPostBack="True"
oncheckedchanged="RadioButton3_CheckedChanged" Text="Euro to Rupee" />
<asp:RadioButton ID="RadioButton4" runat="server" AutoPostBack="True"
oncheckedchanged="RadioButton4_CheckedChanged" Text="Rupee to Euro" />
</form>
</body>
</html>
Default.aspx.cs using
System; using
System.Collections.Ge
neric; using
27 | P a g e
System.Linq; using
System.Web; using
System.Web.UI; using
System.Web.UI.WebCont
rols; public class
Class1
{ public double r, e, d;
public Class1()
{ r
= 0; e
= 0; d
= 0; }
public void convertdtor()
{
double ev = 60;
r = d * ev;
}
public void convertetor()
{
double ev = 80;
r = e * ev;
}
public void convertrtod()
{
double ev = 65;
d = r / ev;
}
public void convertrtoe()
{
double ev = 80;
e = r / ev;
} }
public partial class _Default : System.Web.UI.Page
{
Class1 f1;
protected void Page_Load(object sender, EventArgs e)
{
f1 = new Class1();
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton1.Checked == true)
{
f1.d = Convert.ToInt16(TextBox1.Text);
f1.convertdtor();
Response.Write(f1.d + " Dollar " + " = Rs." + f1.r);
}
28 | P a g e
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton2.Checked == true)
{
f1.r = Convert.ToInt16(TextBox1.Text);
f1.convertrtod();
Response.Write(f1.r + " Rupee " + " = $" + f1.d);
}
}
protected void RadioButton3_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton3.Checked == true)
{
f1.e = Convert.ToInt16(TextBox1.Text);
f1.convertetor();
Response.Write(f1.e + " Euro " + " = Rs." + f1.r);
}
}
protected void RadioButton4_CheckedChanged(object sender, EventArgs e)
{
if (RadioButton4.Checked == true)
{
f1.r = Convert.ToInt16(TextBox1.Text);
f1.convertrtoe();
Response.Write(f1.r + "=Rs to Euro " + f1.e);
}
}
}
Output
iii)Quadratic Equations
Design
29 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Default.aspx.cs using
System;
30 | P a g e
using System.Collections.Generic;
using System.Linq; using
System.Web; using System.Web.UI;
using System.Web.UI.WebControls; class
Quadraticroots
{ public double a, b, c, r1, r2;
public double compute()
{ int m;
double d1; d1 = b * b -
4 * a * c; if (d1 == 0)
{
r1 = r2 = (-b) / (2 * a);
return d1;
}
else if (d1 > 0)
{
r1 = (-b + Math.Sqrt(d1)) / (2 * a);
return d1;
}
else {
r1 = (-b) / (2 * a); r2
= Math.Sqrt(-d1) / (2 * a); return
d1;
}
} }
public partial class _Default : System.Web.UI.Page
{
Quadraticroots q;
protected void Page_Load(object sender, EventArgs e)
{
q = new Quadraticroots();
}
protected void Button1_Click(object sender, EventArgs e)
{
q.a = Convert.ToInt16(TextBox1.Text);
q.b = Convert.ToInt16(TextBox2.Text);
q.c = Convert.ToInt16(TextBox3.Text); double d = q.compute();
if (d == 0)
{
Response.Write("\nRoots are Real and Equal <br>");
Response.Write("First and Second root is "+q.r1);
}
else if (d < 0)
{
Response.Write("\nRoots are Real and Distinct<br>");
Response.Write("\nFirst root is: "+q.r1+"<br>");
31 | P a g e
Response.Write("\nSecond root is: " + q.r2 + "<br>"); }
else
{
Response.Write("\nRoots are Imaginary<br>");
Response.Write("\nFirst root is: " + q.r1 + "<br>");
Response.Write("\nSecond root is: " + q.r2 + "<br>");
}
}
Output
iv)Temperature Conversion
Design
32 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</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;
class converttemp
{
public float celsius, faren;
public converttemp()
{ celsius
= 0; faren =
0;
}
public void converttofaren()
{
faren = ((celsius * 9.0f / 5.0f) + 32.0f);
}
33 | P a g e
public void converttocel()
{
celsius = (faren - 32) * (5.0f / 9.0f);
}
}
public partial class _Default : System.Web.UI.Page
{
converttemp c;
protected void Page_Load(object sender, EventArgs e)
{
c = new converttemp();
}
protected void Button1_Click(object sender, EventArgs e)
{
char ch;
ch = Convert.ToChar(TextBox1.Text);
if (ch == 'c')
{
c.celsius = float.Parse(TextBox2.Text);
c.converttofaren();
Label1.Text = "Celsius to Farenheit: " + c.faren;
}
else
{
c.faren = float.Parse(TextBox2.Text);
c.converttocel();
Label1.Text = "Farenheit to Celsius: " + c.celsius;
}
}
}
Output
34 | P a g e
b) Create simple application to demonstrate use of following concepts
i. Function Overloading
Design
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</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;
class overloading
{
35 | P a g e
public int sum(int a, int b)
{
int x;
return x = a + b;
}
public int sum(int a, int b,int c)
{
int y;
return y = a + b + c;
}
public float sum(float a, float b)
{ float u;
return u = a + b;
}
public float sum(float a, float b, float c)
{
float v;
return v = a + b + c;
} }
public partial class _Default : System.Web.UI.Page
{
overloading o;
protected void Page_Load(object sender, EventArgs e)
{
o = new overloading();
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = Convert.ToString(o.sum(10,20));
Label2.Text = Convert.ToString(o.sum(10,20,30));
Label3.Text = Convert.ToString(o.sum(12.0f,23.1f,32.5f));
}
}
Output
ii)Inheritance Single
Inheritance
Design
36 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</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 class basec
{
public int d;
public string basemethod()
{
string p = "This is baseclass method";
return p;
} }
public class Derived : basec
{
public string derivedmethod()
{
string s = "This is derivedclass method";
return s;
} }
public partial class _Default : System.Web.UI.Page
{
37 | P a g e
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
basec b = new basec();
Response.Write("Calling from base class object: " + b.basemethod());
Derived d = new Derived();
Response.Write("<br>Calling from derived class method:<br>" +
d.basemethod());
Response.Write("<br>" + d.derivedmethod());
}
}
Output
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
38 | P a g e
</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;
class A {
public string show()
{
return ("First base Class");
} }
class B : A
{
public string display()
{
return ("Second base Class");
} }
class C : B
{
public string show1()
{
return ("Child Class");
} }
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
C obj = new C();
Response.Write(obj.show()+"<br>");
Response.Write(obj.display()+"<br>");
Response.Write(obj.show1()+"<br>");
}
}
Output
39 | P a g e
C)Multiple Inheritance
Design
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</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;
class Shape
40 | P a g e
{ public int side; public void
setSide(int s)
{ side
= s;
} }
public interface Cost
{
int getCost(int area);
}
class square : Shape, Cost
{
public int getArea()
{
return (side * side);
}
public int getCost(int area)
{
return area * 10;
} }
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
square sq = new square();
int area; sq.setSide(15);
area = sq.getArea(); Label1.Text =
"Area: " + area; int c =
sq.getCost(area); Label2.Text =
"Cost is Rs: " + c;
}
}
Output
D) Hierarchical Inheritance
Design
41 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</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;
class A {
public string show()
{
return ("Welcome");
} }
class B : A
{
public string display()
{
return (" to the World");
} }
class C : A
42 | P a g e
{ public string show1()
{
return (" Of Programming");
} }
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
C c1 = new C();
B b1 = new B();
string s = ""; s +=
c1.show(); s +=
b1.display(); s +=
c1.show1();
Label1.Text = s;
}
}
Output
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
43 | P a g e
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="height: 29px" Text="Button" />
</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;
class Marksheet
{
public float m1, m2, m3;
string name; public
Marksheet()
{ m1
= 20; m2
= 40; m3
= 40; }
public Marksheet(float ms)
{ m1
= ms; }
public Marksheet(float ms1, float ms2)
{ m1 =
ms1; m2 =
ms2; }
public Marksheet(float ms1, float ms2,float ms3)
{ m1 =
ms1; m2 =
ms2; m3 =
ms3; }
public float tot()
{
float t = m1 + m2 + m3;
return t;
} }
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Marksheet a = new Marksheet();
44 | P a g e
Marksheet b = new Marksheet(90);
Marksheet c = new Marksheet(88,60);
Marksheet d = new Marksheet(70, 90, 55);
Response.Write("In marksheet 1:");
Response.Write(a.tot()+"<br>");
Response.Write("In marksheet 2:");
Response.Write(b.tot()+"<br>");
Response.Write("In marksheet 3:");
Response.Write(c.tot()+"<br>");
Response.Write("In marksheet 4:");
Response.Write(d.tot()+"<br>");
}
}
Output
iv)Interfaces Design
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
45 | P a g e
</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 interface ITransactions
{ string
retcode(); double
amtfunc();
}
public class Transaction : ITransactions
{ private string tCode;
private double amount;
public Transaction()
{ tCode =
""; amount =
0.0;
}
public Transaction(string c, double a)
{ tCode
= c; amount
= a;
}
public double amtfunc()
{
return amount;
}
public string retcode()
{
return tCode;
} }
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Transaction t1 = new Transaction("Cr", 780.00);
Transaction t2 = new Transaction("Db", 400.00);
Response.Write("<br>Code: " + t1.retcode());
Response.Write("<br>Amount: " + t1.amtfunc());
Response.Write("<br>Code: " + t2.retcode());
Response.Write("<br>Amount: " + t2.amtfunc());
46 | P a g e
}
}
Output
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
</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;
47 | P a g e
public delegate void SimpleDelegate();
public void callingFunction()
{
Response.Write("First Function Called.....<br>");
}
public void secfunction()
{
Response.Write("Second Function Called.....<br>");
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SimpleDelegate sd = new SimpleDelegate(callingFunction);
sd();
sd += new SimpleDelegate(secfunction);
sd();
}
}
Output
Default.aspx
48 | P a g e
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</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; class
NegativeException : Exception
{
public NegativeException(string msg)
: base(msg)
{
} }
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
num; try
{
49 | P a g e
num = int.Parse(TextBox1.Text);
if (num < 0)
throw new NegativeException("Negative Number");
else
Console.WriteLine("Positive Number");
}
catch (NegativeException en)
{
Response.Write(en.Message);
}
}
}
Output
50 | P a g e
Practical3
Default.aspx
51 | P a g e
<!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>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="style1">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Rno"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Class"></asp:Label>
</td>
<td>
<asp:RadioButton ID="RadioButton1" runat="server" Text="FY" />
<asp:RadioButton ID="RadioButton2" runat="server" Text="SY" />
<asp:RadioButton ID="RadioButton3" runat="server" Text="TY" />
</td>
</tr>
52 | P a g e
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Course"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>B.Com</asp:ListItem>
<asp:ListItem>BMS</asp:ListItem>
<asp:ListItem>B.SC(IT)</asp:ListItem>
<asp:ListItem>B.SC(CS)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<div>
</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;
53 | P a g e
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string s;
if (RadioButton1.Checked == true)
{
s = RadioButton1.Text;
}
if (RadioButton2.Checked == true)
{
s = RadioButton2.Text;
}
else
{
s = RadioButton3.Text;
}
Label5.Text += "in " + s;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label5.Text = "You have been enrolled in" + DropDownList1.SelectedItem;
}
}
Output
54 | P a g e
3b)Demonstrate the use of Calendar control to perform following operations.
a) Display messages in a calendar control Design
55 | P a g e
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
56 | P a g e
<div>
</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;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
57 | P a g e
{
if (e.Day.Date.Day == 18)
e.Cell.Controls.Add(new LiteralControl("</br>Holiday"));
}
Output
58 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
59 | P a g e
<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" onselectionchanged="Calendar1_SelectionChanged"
Width="330px"> <DayHeaderStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333"
Height="8pt" />
<DayStyle BackColor="#CCCCCC" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="White" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TitleStyle BackColor="#333399" BorderStyle="Solid" Font-Bold="True"
Font-Size="12pt" ForeColor="White" Height="12pt" />
<TodayDayStyle BackColor="#999999" ForeColor="White" />
</asp:Calendar>
</div>
</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;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
60 | P a g e
if ((e.Day.Date >= new DateTime(2018, 09, 18)) && (e.Day.Date <= new DateTime(2018, 09, 25)))
{
e.Cell.BackColor=System.Drawing.Color.Blue;
e.Cell.BorderColor = System.Drawing.Color.Black;
e.Cell.BorderWidth = new Unit(3);
}
}
Output
61 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
62 | P a g e
<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" onselectionchanged="Calendar1_SelectionChanged"
Width="330px"> <DayHeaderStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333"
Height="8pt" />
<DayStyle BackColor="#CCCCCC" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="White" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TitleStyle BackColor="#333399" BorderStyle="Solid" Font-Bold="True"
Font-Size="12pt" ForeColor="White" Height="12pt" />
<TodayDayStyle BackColor="#999999" ForeColor="White" />
</asp:Calendar>
</div>
</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;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if ((e.Day.Date >= new DateTime(2018, 09, 9)) && (e.Day.Date <= new DateTime(2018, 09, 18)))
{
63 | P a g e
e.Cell.BackColor = System.Drawing.Color.Cyan;
e.Cell.BorderColor = System.Drawing.Color.Black;
e.Cell.BorderWidth = new Unit(3);
}
if (e.Day.IsOtherMonth)
{
e.Cell.Controls.Clear();
}
}
}
Output
64 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
65 | P a g e
"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>
</div>
</form>
</body>
</html>
Default.aspx.cs
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq; using
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
66 | P a g e
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.Date.Day == 18)
e.Cell.Controls.Add(new LiteralControl("</br>Holiday")); if ((e.Day.Date >= new
DateTime(2018, 09, 23)) && (e.Day.Date <= new DateTime(2018, 09, 30)))
{
e.Cell.BackColor = System.Drawing.Color.Blue;
e.Cell.BorderColor = System.Drawing.Color.Black;
e.Cell.BorderWidth = new Unit(3);
}
if ((e.Day.Date >= new DateTime(2018, 07, 09)) && (e.Day.Date <= new DateTime(2018, 07, 18)))
{
e.Cell.BackColor = System.Drawing.Color.Cyan;
e.Cell.BorderColor = System.Drawing.Color.Black;
e.Cell.BorderWidth = new Unit(3);
}
if (e.Day.IsOtherMonth)
{
e.Cell.Controls.Clear();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
TimeSpan t = Calendar1.SelectedDate - Calendar2.SelectedDate;
Label1.Text += t.Days.ToString();
}
}
Output
67 | P a g e
3c)Demonstrate the use of Treeview control perform following operations.
Treeview control and datalist
Design
68 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
69 | P a g e
<asp:TreeView ID="TreeView1" runat="server">
<Nodes>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="Course" Value="Course">
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="BSC(IT)"
Value="BSC(IT)"></asp:TreeNode>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="B.Com"
Value="B.Com"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<br />
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<%# Eval("text") %>>
</ItemTemplate>
</asp:DataList>
</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;
}
protected void Button1_Click(object sender, EventArgs e)
{
TreeNodeCollection T;
T = TreeView1.CheckedNodes;
70 | P a g e
DataList1.DataSource = T;
DataList1.DataBind();
DataList1.Visible = true;
}
}
Output
Treeview operations
Design
71 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:TreeView ID="TreeView1" runat="server"
72 | P a g e
onselectednodechanged="TreeView1_SelectedNodeChanged">
<Nodes>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="Course" Value="Course">
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="BSC(IT)" Value="BSC(IT)">
<asp:TreeNode Text="FY" Value="FY"></asp:TreeNode>
<asp:TreeNode Text="SY" Value="SY"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Checked="True" ShowCheckBox="True" Text="B.Com" Value="B.Com">
<asp:TreeNode Text="FY" Value="FY"></asp:TreeNode>
<asp:TreeNode Text="TY" Value="TY"></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</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;
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
Response.Write("You have selected the option: "+TreeView1.SelectedValue);
}
protected void TreeView1_TreeNodeCollapsed(object sender, TreeNodeEventArgs e)
{
Response.Write("The value Collapsed Was: "+e.Node.Value);
}
}
73 | P a g e
Output
74 | P a g e
Practical 4
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
75 | P a g e
.style1
{
width: 100%;
height: 252px; }
.style3
{
width: 150px;
text-align: center;
}
.style4
{
width: 192px;
text-align: right;
}
.style5
{}
.style7
{
width: 269px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="style1">
<tr>
<td class="style4">
<asp:Label ID="Label1" runat="server" Text="Enter Name :"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="TextBox1" runat="server" Width="150px"></asp:TextBox>
</td>
<td class="style7">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="*Name
Required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4">
76 | P a g e
<asp:Label ID="Label2" runat="server" Text="Enter Password :"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"
Width="150px"></asp:TextBox>
</td>
<td class="style7">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2" ErrorMessage="*Password
Required"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label3" runat="server" Text="Confirm Password :"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="TextBox3" runat="server" TextMode="Password"
Width="150px"></asp:TextBox>
</td>
<td class="style7">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="TextBox3" Display="Dynamic"
ErrorMessage="*Password Required"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox2" ControlToValidate="TextBox3"
ErrorMessage="*Enter Same Password"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label4" runat="server" Text="Enter Your Age :"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="TextBox4" runat="server" Width="150px"></asp:TextBox>
</td>
<td class="style7">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox4" Display="Dynamic" ErrorMessage="*Enter
Age"></asp:RequiredFieldValidator>
77 | P a g e
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox4"
ErrorMessage="*Age Required should be between 21 to 30" MaximumValue="30"
MinimumValue="21"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label5" runat="server" Text="Enter Your Email Id :"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="TextBox5" runat="server" Width="150px"></asp:TextBox>
</td>
<td class="style7">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="TextBox5" Display="Dynamic"
ErrorMessage="*Email Id Required"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox5" ErrorMessage="*Email Id should be proper"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style4">
<asp:Label ID="Label6" runat="server" Text="User Id :"></asp:Label>
</td>
<td class="style3">
<asp:TextBox ID="TextBox6" runat="server" Width="150px"></asp:TextBox>
</td>
<td class="style7">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="TextBox6" Display="Dynamic" ErrorMessage="*User Id
Required"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="TextBox6" ErrorMessage="*User Id should write properly"
onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
</td>
</tr>
<tr>
<td class="style4">
</td>
78 | P a g e
<td class="style3">
<asp:Button ID="Button1" runat="server" CssClass="style5" Text="Button" />
</td>
<td class="style7">
</td>
</tr>
</table>
</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;
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
string str = args.Value;
args.IsValid = false;
if (str.Length < 7 || str.Length > 20)
{
return;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("Submitted");
}}
Output
79 | P a g e
80 | P a g e
b) Create Web Form to demonstrate use of Adrotator Control. Design
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Default.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
81 | P a g e
<!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>
</div>
</form>
</body>
</html>
Output
82 | P a g e
Default.aspx
83 | P a g e
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:TextBox ID="TextBox2" runat="server"
ontextchanged="TextBox2_TextChanged"></asp:TextBox></br>
<uc1:WebUserControl runat="server" id="WebUserControl1"/>
</div>
</form>
</body>
</html>
WebUserControl.ascx
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq; using
System.Web; using
System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Button1_Click(object sender, EventArgs e)
84 | P a g e
{
TextBox2.Text = "hello Guest: " + TextBox1.Text;
}
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
}
}
WebUserControl.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq; using
System.Web; using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox2.Text = "Welcome " + TextBox1.Text;
}
protected void TextBox2_TextChanged(object sender, EventArgs e)
{
}
}
Output
85 | P a g e
Practical 5
a) Create Web Form to demonstrate use of Website Navigation controls and Site
Map.
Design
86 | P a g e
87 | P a g e
Default.aspx
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
</asp:Menu>
88 | P a g e
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</form>
</body>
</html>
========================================================
Default2.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
=============================================================
Default3.aspx
89 | P a g e
<!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>
</div>
</form>
</body>
</html>
========================================================
Web.sitemap
Output
90 | P a g e
b) Create a web application to demonstrate use of Master Page with applying
Styles and Themes for page beautification.
Design
91 | P a g e
92 | P a g e
93 | P a g e
Default.aspx
MasterPage.master
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">Vodafone Mobile Store</p>
<title>Vodafone Mobile Store</title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
94 | P a g e
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Default.aspx
=============================================================
Default2.aspx
================================================================
StyleSheet.css
95 | P a g e
body
{
background-color:Gray;
font:italic|Arial|12;
}
================================================
SkinFile.skin
<%--
Default skin template. The following skins are provided as examples only.
96 | P a g e
Output
97 | P a g e
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
98 | P a g e
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="View State" />
<br />
<br />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click"
Text="Hidden Field" />
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="Button3" runat="server" onclick="Button3_Click"
Text="Cookies" />
</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;
99 | P a g e
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = ViewState["count"].ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
if (HiddenField1.Value != null)
{
int val = Convert.ToInt32(HiddenField1.Value) + 1;
HiddenField1.Value = val.ToString();
}
}
protected void Button3_Click(object sender, EventArgs e)
{
HttpCookie h = new HttpCookie("name");
h.Value = TextBox1.Text;
Response.Cookies.Add(h);
Response.Redirect("Default2.aspx");
}
}
Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</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;
100 | P a g e
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["name"] != null)
Response.Write("Welcome: "+Request.Cookies["name"].Value);
}
}
Output
101 | P a g e
Practical 6
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
102 | P a g e
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"
Width="268px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
</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.Data.SqlClient;
TextBox2.Text+=ds[0].ToString()+"\t"+ds[1].ToString()+"\t"+ds[2].ToString()+"
\n";
}
}
}
103 | P a g e
Output
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
104 | P a g e
<div>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [stdetail]"></asp:SqlDataSource>
</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.Data.SqlClient;
Output
105 | P a g e
Demonstrate the use of Datalist link control
Drag and Drop Data list control, SQLDATASOURCE control.
Right click on the SQLDATASOURCE control.
Click on configure data source.
Choose your Data Connection.
106 | P a g e
Select the table to connect.
107 | P a g e
Click on finish button Run the program.
108 | P a g e
Practical 7
Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
109 | P a g e
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [stdetail]"></asp:SqlDataSource>
</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.Data.SqlClient;
110 | P a g e
Output
111 | P a g e
b) Create a web application for to display the phone no of an author using
database
Design
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
112 | P a g e
</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.Data.SqlClient;
Output
113 | P a g e
c)Create a web application for inserting and deleting record from a database.
(Using Execute-Non Query). Design
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
114 | P a g e
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
115 | P a g e
</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.Data.SqlClient;
116 | P a g e
GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
co.CommandText = "delete from stdetail where sno='" + TextBox1.Text +
"';";
co.ExecuteNonQuery();
}
}
Output
117 | P a g e