0% found this document useful (0 votes)
34 views75 pages

AWP Practical New

The document outlines several practical applications created in C# for various programming concepts. These include basic arithmetic operations, generating Floyd's triangle, Fibonacci series, prime number testing, boxing and unboxing, and using delegates and interfaces. Each practical includes code snippets and aims to demonstrate specific programming functionalities.

Uploaded by

itssatyam Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views75 pages

AWP Practical New

The document outlines several practical applications created in C# for various programming concepts. These include basic arithmetic operations, generating Floyd's triangle, Fibonacci series, prime number testing, boxing and unboxing, and using delegates and interfaces. Each practical includes code snippets and aims to demonstrate specific programming functionalities.

Uploaded by

itssatyam Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 75

Practical 1.

Aim: Create an application to print on screen the output of adding, subtracting, multiplying and dividing two
numbers entered by the user in C#.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewPract1a
{
class Program
{
static void Main(string[] args)
{
Console.Write("NAME : SANDESH \n\n");
// Prompt the user to enter the first number
Console.Write("Enter the first number: ");
double num1 = Convert.ToDouble(Console.ReadLine());

// Prompt the user to enter the second number


Console.Write("Enter the second number: ");
double num2 = Convert.ToDouble(Console.ReadLine());

// Perform the operations


double addition = num1 + num2;
double subtraction = num1 - num2;
double multiplication = num1 * num2;
double division = num2 != 0 ? num1 / num2 : double.NaN;

// Display the results


Console.WriteLine($"\nResults:");
Console.WriteLine($"Addition: {num1} + {num2} = {addition}");
Console.WriteLine($"Subtraction: {num1} - {num2} = {subtraction}");
Console.WriteLine($"Multiplication: {num1} * {num2} = {multiplication}");
if (num2 != 0)
{
Console.WriteLine($"Division: {num1} / {num2} = {division}");
}
else
{
Console.WriteLine("Division: Cannot divide by zero.");
}
Console.ReadKey();
}

}
}
Output:
Practical 1.b

Aim: Create an application to print Floyd’s triangle till n rows in C#.


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace newPract1b
{
class Program
{
static void Main(string[] args)
{
Console.Write("NAME :Sandesh \n\n");
// Prompt the user to enter the number of rows for Floyd's triangle
Console.Write("Enter the number of rows for Floyd's Triangle: ");
int n = Convert.ToInt32(Console.ReadLine());

// Initialize the starting number


int number = 1;

// Generate Floyd's Triangle


Console.WriteLine("\nFloyd's Triangle:");
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
{
Console.Write(number + " ");
number++;
}
Console.WriteLine(); // Move to the next line after each row
}
Console.ReadKey();
}
}
}

Output:
Practical 1.c

Aim: Create an application to demonstrate following operations


i. Generate Fibonacci series. ii. Test for prime numbers.

Design:
Home Page.aspx

Source Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Home Page.aspx.cs"
Inherits="Pract1_d_.Home_Page" %>

<!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="Practical 1 - c - i :"></asp:Label>
&nbsp;<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/WebForm1.aspx">Generate
Fibonacci series.</asp:HyperLink>
<br />
<asp:Label ID="Label2" runat="server" Text="Practical 1 - c- ii :"></asp:Label>
&nbsp;<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/WebForm2.aspx">Test for prime
numbers.</asp:HyperLink>
<br />
</div>
</form>
</body>
</html>

WebForm1.aspx (Generate Fibonacci series.)

Source Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="Pract1_d_.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:Label ID="Label1" runat="server" Text="Enter The Number of Elements in
Fibonacci Series: "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Generate
Fibonacci Series" />
</div>
</form>
</body>
</html>

WebForm2.aspx (Test for prime numbers.)

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Enter a Number:"></asp:Label>&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Check for
Prime No" />
</div>
</form>
</body>
</html>

Code:
WebForm1.aspx (Generate Fibonacci series.)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button1_Click(object sender, EventArgs e)


{
int f1 = 0, f2 = 1, f3, n, co;
n = int.Parse(TextBox1.Text);
co = 3;
Response.Write("Fibonacci Series:");
Response.Write(f1+"\t"+f2);
while(co<=n)
{
f3 = f1 + f2;
Response.Write("\t" + f3);
f1 = f2;
f2 = f3;
co++;
}
}
}
}

WebForm2.aspx (Test for prime numbers.)


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

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

protected void Button1_Click(object sender, EventArgs e)


{
int n, i, c;
n = int.Parse(TextBox1.Text);
for (c = 2;c<=n-1;c++)
{
if (n % c == 0)
break;
}
if (n == 1)
Response.Write(n + " is neither prime nor composite");
else if (c<n-1)
Response.Write(n + " is not Prime Number");
else
Response.Write(n + " is Prime Number");
}
}
}

Output

Home Page
WebForm1.aspx (Generate Fibonacci series.)

WebForm2.aspx (Test for prime numbers.)


Practical 2a
Aim: Create a simple application to demonstrate the concepts boxing and unboxing.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewPract2_a_
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("NAME: Sandesh \n\n");
// Boxing: Converting a value type (int) to an object
int num = 123; // Value type
object obj = num; // Boxing - num is converted to an object
obj = 145;

// Display the boxed value


Console.WriteLine("Boxing:");
Console.WriteLine($"Value type (int): {num}");
Console.WriteLine($"Boxed type (object): {obj}");

// Unboxing: Converting an object back to a value type


int unboxedNum = (int)obj; // Unboxing - obj is converted back to an int

// Display the unboxed value


Console.WriteLine("\nUnboxing:");
Console.WriteLine($"Boxed type (object): {obj}");
Console.WriteLine($"Value type (int): {num}");
Console.WriteLine($"Unboxed type (int): {unboxedNum}");
Console.ReadKey();
}
}
}

Output:
Practical 2b
Aim: Create a simple application to perform addition and subtraction using delegate
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewPract2b
{
// Define a delegate that takes two integers and returns an integer
public delegate int Operation(int x, int y);

class Program
{
// Method to perform addition
public static int Add(int x, int y)
{
return x + y;
}

// Method to perform subtraction


public static int Subtract(int x, int y)
{
return x - y;
}

static void Main(string[] args)


{
Console.Write("NAME: Sandesh \n\n");
// Create delegate instances
Operation addOperation = new Operation(Add);
Operation subtractOperation = new Operation(Subtract);

// Input numbers
Console.Write("Enter the first number: ");
int num1 = int.Parse(Console.ReadLine());

Console.Write("Enter the second number: ");


int num2 = int.Parse(Console.ReadLine());

// Perform addition
int additionResult = addOperation(num1, num2);
Console.WriteLine($"Addition Result: {additionResult}");

// Perform subtraction
int subtractionResult = subtractOperation(num1, num2);
Console.WriteLine($"Subtraction Result: {subtractionResult}");

// Wait for user input before closing


Console.ReadKey();
}
}
}

Output:
Practical 2c
Aim: Create a simple application to demonstrate use of the concepts of interfaces.
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Interface.aspx.cs"
Inherits="NewPract2c.Interface" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2> simple application to demonstrate use of the concepts of interfaces. </h2>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<h4>NAME: Sandesh </h4>
</div>
</form>
</body>
</html>

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

namespace NewPract2c
{
public interface Itransactions
{
//interface member
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 Interface : 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());
}
}
}

Output:
Practical 3a
Aim: Create a simple web page with various server controls to demonstrate setting and use of their
properties. (Example : AutoPostBack)
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract 3 a.aspx.cs"
Inherits="Practical_3.Pract_3_a" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 50%;
border:3px solid navy;
background-color:#a7a122
}
.auto-style4 {
text-align: center;
height: 46px;
}
.auto-style12 {
height: 47px;
}
.auto-style13 {
width: 215px;
height: 56px;
}
.auto-style14 {
height: 56px;
width: 289px;
}
.auto-style15 {
width: 215px;
height: 54px;
}
.auto-style16 {
height: 54px;
width: 289px;
}
.auto-style17 {
width: 215px;
height: 52px;
}
.auto-style18 {
height: 52px;
width: 289px;
}
.auto-style19 {
width: 215px;
height: 49px;
}
.auto-style20 {
height: 49px;
width: 289px;
}
body{
background-color:#e4cfcf
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style13">
<asp:Label ID="Label1" runat="server" Text="RNo"></asp:Label>
</td>
<td class="auto-style14">
<asp:TextBox ID="TextBox1" runat="server" TabIndex="1"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style15">
<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>
</td>
<td class="auto-style16">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style17">
<asp:Label ID="Label3" runat="server" Text="Class"></asp:Label>
</td>
<td class="auto-style18">
<asp:RadioButton ID="RadioButton1" runat="server" Text="FY" GroupName="Class" />
&nbsp;<asp:RadioButton ID="RadioButton2" runat="server" Text="SY" GroupName="Class" />
&nbsp;<asp:RadioButton ID="RadioButton3" runat="server" Text="TY" GroupName="Class" />
</td>
</tr>
<tr>
<td class="auto-style19">
Course</td>
<td class="auto-style20">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" TabIndex="2">
<asp:ListItem>B.Com</asp:ListItem>
<asp:ListItem>BMS</asp:ListItem>
<asp:ListItem>B.Sc.(I.T.)</asp:ListItem>
<asp:ListItem>B.Sc.(CS)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style4" colspan="2">
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"
AccessKey="S" TabIndex="3" ToolTip="Please Submit Youe Data" />
</td>
</tr>
<tr>
<td class="auto-style12" colspan="2">
<asp:Label ID="Label5" runat="server" Text=" "></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

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

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

protected void Button1_Click(object sender, EventArgs e)


{

string s = "You have been enrolled in ";


if (RadioButton1.Checked == true)
{
s += RadioButton1.Text;
}
else if (RadioButton2.Checked == true)
{
s += RadioButton2.Text;
}
else if (RadioButton3.Checked == true)
{
s += RadioButton3.Text;
}
s += DropDownList1.SelectedItem;
Label5.Text = s;
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{
Response.Write("You have selected " + DropDownList1.SelectedItem + " Course");
}
}
}
Output:
Practical 3b
Aim: Create a simple application to demonstrate your vacation using calendar control.
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract 3bb.aspx.cs"
Inherits="Practical_3.Pract_3bb" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar ID="Calendar1" runat="server" NextMonthText="Next"
OnDayRender="Calendar1_DayRender" PrevMonthText="Pre" SelectionMode="DayWeekMonth"
BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt"
ForeColor="Black" Height="190px" NextPrevFormat="FullMonth"
OnSelectionChanged="Calendar1_SelectionChanged" Width="350px">
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333"
VerticalAlign="Bottom" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True"
Font-Size="12pt" ForeColor="#333399" />
<TodayDayStyle BackColor="#CCCCCC" />
</asp:Calendar>

<h4>NAME: SANDESH </h4>


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

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

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

}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if ((e.Day.Date >= new DateTime(2024, 09, 7)) && (e.Day.Date <= new DateTime(2024, 09, 12)))
{
e.Cell.BackColor = System.Drawing.Color.Navy;
e.Cell.BorderColor = System.Drawing.Color.Black;
e.Cell.ForeColor= System.Drawing.Color.White;
e.Cell.BorderWidth = new Unit(3);
if (e.Day.Date == new DateTime(2024, 09, 7))
{
e.Cell.Controls.Add(new LiteralControl("/br Ganpati Vacation Start"));
}
if (e.Day.Date == new DateTime(2024, 09, 12))
{
e.Cell.Controls.Add(new LiteralControl("/br Ganpati Vacation End"));
}
}
}

protected void Calendar1_SelectionChanged(object sender, EventArgs e)


{
if (Calendar1.SelectedDate.Date >= new DateTime(2024, 09, 7) && Calendar1.SelectedDate.Date
<= new DateTime(2024, 09, 12))
Response.Write("</br><h1>Ganpati Vacation..... Go to your village and worship Lord
Ganesh</h1></br>");
}
}
}
Output:
Practical 3c
Aim: Demonstrate the use of Treeview operations on the web form
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract3c.aspx.cs"
Inherits="Practical_3.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 Contorl Navigation:
<asp:TreeView ID="TreeView1" runat="server"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" ShowCheckBoxes="All"
OnTreeNodeCollapsed="TreeView1_TreeNodeCollapsed" ShowLines="True">
<HoverNodeStyle BackColor="#FF99FF" ForeColor="#003300" />
<LeafNodeStyle BackColor="#99CCFF" ForeColor="#663300" />
<Nodes>
<asp:TreeNode Text="AWP Practical" Value="AWP Practical">
<asp:TreeNode Text="Practical 3" Value="Practical 3">
<asp:TreeNode Text="Practical 3a" Value="Practical 3a" NavigateUrl="~/Pract 3 a.aspx"
Target="new"/>
<asp:TreeNode Text="Practical 3b" Value="Practical 3b" NavigateUrl="~/Pract 3
b.aspx">
<asp:TreeNode Text="Practical 3b b" Value="Practical 3b b" NavigateUrl="~/Pract
3bb.aspx"></asp:TreeNode>
<asp:TreeNode Text="Practical 3bc" Value="Practical 3bc"
NavigateUrl="~/Pract3bd.aspx"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="Practical 3c" Value="Practical 3c"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="Website" Value="Website">
<asp:TreeNode Text="Mumbai University" Value="Mumbai University"
NavigateUrl="https://mu.ac.in/">
<asp:TreeNode Text="GD Jalan" Value="GD Jalan"
NavigateUrl="https://gdjalan.edu.in/"></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
<ParentNodeStyle BackColor="#66FF99" ForeColor="#000099" />
<RootNodeStyle BackColor="#FFFF99" ForeColor="#990000" />
<SelectedNodeStyle BackColor="Black" ForeColor="White" />
</asp:TreeView>

<br />
<br />
<asp:Label ID="Label1" runat="server" BackColor="#FFFF99" Font-Bold="True" Font-
Size="20pt"></asp:Label>
<br />
<br />
<br />
<h4>NAME: Sandesh </h4>

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

Code:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Practical_3
{
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("XMLFile1.xml"));
if (ds!= null && ds.HasChanges())
{
DataList1.DataSource = ds;
DataList1.DataBind();
}
else
{
DataList1.DataBind();
}*/
}

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)


{
Label1.Text = "You have selected the option:" + TreeView1.SelectedValue;
}

protected void TreeView1_TreeNodeCollapsed(object sender, TreeNodeEventArgs e)


{
Label1.Text = "The Value Collapsed was:" + e.Node.Value;
}
}
}
Output:
Practical 4a
Aim: Create a Registration form to demonstrate use of various Validation controls.
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="4aValidate Contorl Form.aspx.cs"
Inherits="Pract_4_a.Validate_Contorl_Form" %>

<!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="Enter Password"></asp:Label>
&nbsp;<asp:TextBox ID="TextBox1" runat="server" TextMode="Password"></asp:TextBox>
&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Password Required"
ForeColor="Red">*</asp:RequiredFieldValidator>
&nbsp;<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Confirmed Password"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Confirm Password Required"
ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox1"
ControlToValidate="TextBox2" ErrorMessage="Confirm Password Should Match with password">Confirm
Password Should Match with password</asp:CompareValidator>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Enter Your Age "></asp:Label>
&nbsp;<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="TextBox3" ErrorMessage="Age Required"
ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox3"
ErrorMessage="Age Should be between 21 to 30" MaximumValue="30" MinimumValue="21">Age Should
be between 21 to 30</asp:RangeValidator>
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="Enter Your Emai ID"></asp:Label>
&nbsp;<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox4" ErrorMessage="Email Required"
ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox4" ErrorMessage="Please Enter Valid Email" ValidationExpression="\w+([-
+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">Please Enter Valid Email</asp:RegularExpressionValidator>
<br />
<br />
<asp:Label ID="Label5" runat="server" Text="user id"></asp:Label>
&nbsp;<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="TextBox5" ErrorMessage="User Id Required"
ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox5"
ErrorMessage="User Id Length Should be between 7 and 20 characters"
OnServerValidate="CustomValidator1_ServerValidate">User Id Length Should be between 7 and 20
characters</asp:CustomValidator>
<br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<br />
<br />

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

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

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

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("Submitted");
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
string str = args.Value;
args.IsValid=false;
if (str.Length < 7 || str.Length > 20)
args.IsValid = false;
else
args.IsValid = true;
}
}
}
Output:
Practical 4b
Aim: Create Web Form to demonstrate use of Adrotator Control.
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Adrotator 4 b.aspx.cs"
Inherits="Pract_4_a.Adrotator_4_b" %>

<!DOCTYPE html>

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

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

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

}
}
}

XML file:
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>~/Images/Coke.jpg</ImageUrl>
<Impressions>1</Impressions>
<NavigateUrl>https://www.coca-colacompany.com/</NavigateUrl>
<AlternateText>Coke image is missing</AlternateText>
<Keyword>Coke</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Images/Frooti.jpg</ImageUrl>
<Impressions>5</Impressions>
<NavigateUrl>https://gdjalan.edu.in/commerce-faculty-degree-college/ </NavigateUrl>
<Keyword>Frooti</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Images/Pepsi.jpg</ImageUrl>
<Impressions>1</Impressions>
<NavigateUrl>https://www.pepsi.com/</NavigateUrl>
<Keyword>Pepsi</Keyword>
</Ad>
</Advertisements>

Output:
Practical 4c
Aim: Create Web Form to demonstrate use User Controls
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="4C.aspx.cs" Inherits="Pract_4_a._4C"
%>

<%@ Register src="WebUserControl1.ascx" tagname="MyControl" tagprefix="user" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<user:MyControl ID="WebUserControl11" runat="server" />
<div>
<br />
<br />
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/nature.jpeg" />
<br />
<h4>NAME: SANDESH </h4>
</div>
</form>
</body>
</html>

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

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

}
}
}
Output:
Practical 5a
Aim: Create Web Form to demonstrate use of Website Navigation controls.
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="prac_5(A).aspx.cs"
Inherits="Pract_4_a.prac_5_A_" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.menu {
width: 50%;
height:100px;
border:3px solid navy;
background-color:black;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="menu">

<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1"


DisappearAfter="1000" Font-Bold="True" Font-Size="X-Large" ForeColor="White">
<DynamicHoverStyle BackColor="Black" ForeColor="White" />
</asp:Menu>
</div>
<div><h1>Welcome to our website</h1>
<h3>This is the Home Page</h3> <br/></div>

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />


<br />
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
<CurrentNodeStyle BackColor="#CCFFCC" />
</asp:SiteMapPath>
<br />

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

Page 1:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page1.aspx.cs"
Inherits="Pract_4_a.Page1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Welcome to Page 1 of our website</h1>
</div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
</form>
</body>
</html>

Page 2:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page2.aspx.cs"
Inherits="Pract_4_a.Page2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Welcome to Page 2 of our website</h1>
</div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
</form>
</body>
</html>

Page 3:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page3.aspx.cs"
Inherits="Pract_4_a.Page3" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Welcome to Page 3 of our website</h1>
</div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
</form>
</body>
</html>

Page 4:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page4.aspx.cs"
Inherits="Pract_4_a.Page4" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Welcome to Page 4 of our website</h1>
</div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
</form>
</body>
</html>

Output:
Practical 5b
Aim: Create a web application to demonstrate use of Master Page and content page
Design:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
CodeBehind="Pract5b.aspx.cs" Inherits="Pract5.Pract5b" Theme ="Theme1"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.auto-style1 {
height: 29px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2 align="center"> Contact Us</h2>
<h3 align="center"> Fill the datails</h3>
<table class="auto-style1" align="center">
<tr>
<td class="auto-style1">
<asp:Label ID="Label1" runat="server" Text="Name:"></asp:Label>
</td>
<td class="auto-style1">
<asp:TextBox ID="TextBox1" runat="server" SkinID="Yellow"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Email ID:"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" SkinID="Yellow"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style1">
<asp:Label ID="Label3" runat="server" Text="Mobile No."></asp:Label>
</td>
<td class="auto-style1">
<asp:TextBox ID="TextBox3" runat="server" SkinID="Blue"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Your Query"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox4" runat="server" SkinID="Blue"></asp:TextBox>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Button1" runat="server" Text="Submit" SkinID="Green" />

</td>
</tr>
</table>
&nbsp;<br />
</asp:Content>

MasterPage:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"
Inherits="Pract5.Site1" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<style type="text/css">
body{
background-color:powderblue;

}
.head {
background-color:#cc3399;
color:white;
}
footer{
background-color:black;
color:white;
}
</style>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div class ="head">
<h2 align="center">Ghanshyamdas Jalan College of Science & Commerce</h2>
<h4 align="center"> Chinchowli Rd, Malad, Upper Govind Nagar, Malad East, Mumbai,
Maharashtra 400097</h4>
<p align="center"> &nbsp;</p>
</div>
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<footer align="center">Copyright by GD JALAN</footer>
</form>
<h4>NAME: SANDESH</h4>

</body>
</html>
Output:
Practical 5c
Aim: Create a web application to demonstrate various states of ASP.NET Pages.
1. ViewState:
Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract 5 C ViewState.aspx.cs"
Inherits="Pract5.Pract_5_C_ViewState" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
View Variable:
<asp:Label ID="Label1" runat="server" Text="View Data is:"></asp:Label>
<br />
<br />
Session Variable:
<asp:Label ID="Label2" runat="server" Text="Session Variable"></asp:Label>
<br />
<br />
Application Variable:
<asp:Label ID="Label3" runat="server" Text="Application Variable"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Get Data" />
</div>
</form>
<h4>NAME: SANDESH</h4>
</body>
</html>

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

namespace Pract5
{
public partial class Pract_5_C_ViewState : System.Web.UI.Page
{
int count = 0;
protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
if (ViewState["cnt"] == null)
{
//ViewState["cnt"] = count;
ViewState.Add("cnt", count);
}
if (Session["scnt"] == null)
{
//Session["scnt"] = count;
Session.Add("scnt", count);
}
if (Application["acnt"] == null)
{
//Application["acnt"] = count;
Application.Add("acnt", count);
}

}
}

protected void Button1_Click(object sender, EventArgs e)


{
/* count = int.Parse(ViewState["cnt"].ToString());
count++;
ViewState["cnt"] = count;
Label1.Text = ViewState["cnt"].ToString();*/
ViewState["cnt"] = (int)ViewState["cnt"] + 1;
Label1.Text = ViewState["cnt"].ToString();
Session["scnt"] = (int)Session["scnt"] + 1;
Label2.Text = Session["scnt"].ToString();
Application["acnt"] = (int)Application["acnt"] + 1;
Label3.Text = Application["acnt"].ToString();
/*count++;
Label1.Text = count.ToString();*/

}
}
}
Output:
2. QueryString

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract 5c Querystr1.aspx.cs"
Inherits="Pract5.Pract_5c_Querystr1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 68%;
height: 158px;
}
.auto-style2 {
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td colspan="2"> <h2 align ="center"> Query String Example </h2> &nbsp;</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="UserID"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="UserName"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2" colspan="2">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send Data" />
</td>
</tr>
</table>
</div>
</form>
<h4>NAME: SANDESH</h4>
</body>
</html>

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

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

protected void Button1_Click(object sender, EventArgs e)


{
/*Session["userId"] = TextBox1.Text;
Session["userName"] = TextBox2.Text;*/
/*Application["userId"] = TextBox1.Text;
Application["userName"] = TextBox2.Text;*/
//Response.Redirect("~/Pract 5c Querystr2aspx.aspx");
Response.Redirect("~/Pract 5c Querystr2aspx.aspx?userId=" +TextBox1.Text + "&userName=" +
TextBox2.Text );
}
}
}

Output:
3. Session and Application State

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract 5c Session and Application
State.aspx.cs" Inherits="Pract5.Pract_5c_Session_and_Application_State"%>

<!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"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Get Data" />
</div>
</form>
<h4>NAME: SANDESH</h4>
</body>
</html>

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

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

protected void Button1_Click(object sender, EventArgs e)


{
Label1.Text = "";
Application["OnlineApplicationUsers"] = (int)Application["OnlineApplicationUsers"] + 1;
Label1.Text = "Aplication Count " + Application["OnlineApplicationUsers"];

Session["OnlineSessionUsers"] = (int)Session["OnlineSessionUsers"] + 1;
Label1.Text = Label1.Text + "<br> Session Count " + Session["OnlineSessionUsers"];
}
}
}

Output:

4. Cookies

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Practica5cCookies1.aspx.cs"
Inherits="Pract5.Practica5cCookies1" %>

<!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="UserName:"></asp:Label>
&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
User Email:&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
</div>
</form>
<h4>NAME: SANDESH</h4>
</body>
</html>

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

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

protected void Button1_Click(object sender, EventArgs e)


{
HttpCookie cookie = new HttpCookie("UserInfo");
cookie["Name"] = TextBox1.Text;
cookie["Email"] = TextBox2.Text;
cookie.Expires = DateTime.Now.AddDays(3);
//cookie.Expires = DateTime.Now.AddSeconds(100);
Response.Cookies.Add(cookie);
Response.Redirect("~/Practica5cCookies2.aspx");
}
}
}

Output:
Practical 6a
Aim: Create a web application for inserting and deleting records from a database.

Design & Code:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="New_Pract_6a.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Inserting and deleting records from a database</h2>
<asp:DetailsView ID="DetailsView1" runat="server" Height="54px" Width="157px"
AllowPaging="True" AutoGenerateRows="False" BackColor="#DEBA84" BorderColor="#DEBA84"
BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataKeyNames="Cust_Id"
DataSourceID="SqlDataSource1">
<EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="Cust_Id" HeaderText="Cust_Id" ReadOnly="True"
SortExpression="Cust_Id" />
<asp:BoundField DataField="Cust_Name" HeaderText="Cust_Name"
SortExpression="Cust_Name" />
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:CommandField ShowDeleteButton="True" ShowInsertButton="True" />
</Fields>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<FooterTemplate>
Copyright by Ravi Sir
</FooterTemplate>
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<HeaderTemplate>
Customer Details:
</HeaderTemplate>
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:TYConnectionString %>" DeleteCommand="DELETE FROM
[Customer] WHERE [Cust_Id] = @original_Cust_Id AND (([Cust_Name] = @original_Cust_Name) OR
([Cust_Name] IS NULL AND @original_Cust_Name IS NULL)) AND (([State] = @original_State) OR
([State] IS NULL AND @original_State IS NULL)) AND (([City] = @original_City) OR ([City] IS NULL
AND @original_City IS NULL))" InsertCommand="INSERT INTO [Customer] ([Cust_Id], [Cust_Name],
[State], [City]) VALUES (@Cust_Id, @Cust_Name, @State, @City)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [Customer]"
UpdateCommand="UPDATE [Customer] SET [Cust_Name] = @Cust_Name, [State] = @State, [City] =
@City WHERE [Cust_Id] = @original_Cust_Id AND (([Cust_Name] = @original_Cust_Name) OR
([Cust_Name] IS NULL AND @original_Cust_Name IS NULL)) AND (([State] = @original_State) OR
([State] IS NULL AND @original_State IS NULL)) AND (([City] = @original_City) OR ([City] IS NULL
AND @original_City IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_Cust_Id" Type="Int32" />
<asp:Parameter Name="original_Cust_Name" Type="String" />
<asp:Parameter Name="original_State" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Cust_Id" Type="Int32" />
<asp:Parameter Name="Cust_Name" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="City" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Cust_Name" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="original_Cust_Id" Type="Int32" />
<asp:Parameter Name="original_Cust_Name" Type="String" />
<asp:Parameter Name="original_State" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<br />
<asp:FormView ID="FormView1" runat="server" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2"
DataKeyNames="Cust_Id" DataSourceID="SqlDataSource1" GridLines="Both">
<EditItemTemplate>
Cust_Id:
<asp:Label ID="Cust_IdLabel1" runat="server" Text='<%# Bind("Cust_Id") %>' />
<br />
Cust_Name:
<asp:TextBox ID="Cust_NameTextBox" runat="server" Text='<%# Bind("Cust_Name") %>'
/>
<br />
State:
<asp:TextBox ID="StateTextBox" runat="server" Text='<%# Bind("State") %>' />
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
&nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<FooterTemplate>
Copyright by Ravi Sir
</FooterTemplate>
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<HeaderTemplate>
Customer Details:
</HeaderTemplate>
<InsertItemTemplate>
Cust_Id:
<asp:TextBox ID="Cust_IdTextBox" runat="server" Text='<%# Bind("Cust_Id") %>' />
<br />
Cust_Name:
<asp:TextBox ID="Cust_NameTextBox" runat="server" Text='<%# Bind("Cust_Name") %>'
/>
<br />
State:
<asp:TextBox ID="StateTextBox" runat="server" Text='<%# Bind("State") %>' />
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
Cust_Id:
<asp:Label ID="Cust_IdLabel" runat="server" Text='<%# Bind("Cust_Id") %>' />
<br />
Cust_Name:
<asp:Label ID="Cust_NameLabel" runat="server" Text='<%# Bind("Cust_Name") %>' />
<br />
State:
<asp:Label ID="StateLabel" runat="server" Text='<%# Bind("State") %>' />
<br />
City:
<asp:Label ID="CityLabel" runat="server" Text='<%# Bind("City") %>' />
<br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
&nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
&nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
CommandName="New" Text="New" />
</ItemTemplate>
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
</asp:FormView>
<br />
<h4>NAME: SANDESH</h4>
</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>
<connectionStrings>
<add name="TYConnectionString" connectionString="Server=SAKET;Database=TYDatabase;Integrated
Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
compilerOptions="/langversion:default /nowarn:1659;1699;1701;612;618"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
compilerOptions="/langversion:default /nowarn:41008,40000,40008 /define:_MYTYPE=\&quot;Web\
&quot; /optionInfer+" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</compilers>
</system.codedom>
</configuration>

Output:
Practical 6b
Aim: Create a web application to display Using Disconnected Data Access and Databinding using
GridView

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract 6b.aspx.cs"
Inherits="Practical_8.Pract_8c" %>

<!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="Employee Salary &gt;"></asp:Label>
&nbsp;<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&nbsp;
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<br />
<br />
<asp:Label ID="Label2" runat="server"></asp:Label>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" BorderStyle="Ridge" CellPadding="4"
ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</div>
</form>
<h4>NAME: SANDESH</h4>
</body>
</html>

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

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

protected void Button1_Click(object sender, EventArgs e)


{
try
{
// Debugging - Check if TextBox1 is null
if (TextBox1 == null)
{
throw new Exception("TextBox1 is null.");
}

string connStr = WebConfigurationManager.ConnectionStrings["connStr"].ConnectionString;


if (string.IsNullOrEmpty(connStr))
{
Label2.Text = "Connection string not found!";
return;
}
using (SqlConnection con = new SqlConnection(connStr))
{
con.Open();
string sql = "SELECT * FROM Employee WHERE Esalary > @Salary";
using (SqlCommand cmd = new SqlCommand(sql, con))
{
decimal salary;
if (decimal.TryParse(TextBox1.Text, out salary))
{
cmd.Parameters.AddWithValue("@Salary", salary);

SqlDataAdapter da = new SqlDataAdapter(cmd);


DataSet ds = new DataSet();
da.Fill(ds);

// Debugging - Check if dataset is empty


if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
{
Label2.Text = "No records found.";
}
else
{
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
}
else
{
Label2.Text = "Please enter a valid salary.";
}
}
}
}
catch (Exception ex)
{
Label2.Text = "";
Label2.Text = "Invalid Query ..." + ex.Message;
}
}

}
}

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.7.2" />
<httpRuntime targetFramework="4.7.2" />
</system.web>

<connectionStrings>
<add name="connStr" connectionString="Data Source=SAKET;Initial
Catalog=EmployeeDB;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>

</configuration>

Output:
Practical 7a
Aim: Create a web application to demonstrate the use of different types of Cookies.

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CookiesDemo.aspx.cs"
Inherits="New_Pract_7a.CookiesDemo" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta charset="utf-8" />
<title>Cookie Demo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Cookie Demonstration</h2>
<asp:Label ID="lblMessage" runat="server" Text="Cookie Info will appear here." />

<h3>Create Cookies</h3>
<label for="cookieValue">Enter Cookie Value:</label>
<asp:TextBox ID="txtCookieValue" runat="server"></asp:TextBox>
<br /><br />
<asp:Button ID="btnCreateSessionCookie" runat="server" Text="Create Session Cookie"
OnClick="btnCreateSessionCookie_Click" />
<asp:Button ID="btnCreatePersistentCookie" runat="server" Text="Create Persistent Cookie"
OnClick="btnCreatePersistentCookie_Click" />
<asp:Button ID="btnCreateSecureCookie" runat="server" Text="Create Secure Cookie"
OnClick="btnCreateSecureCookie_Click" />
<br /><br />

<h3>Retrieve Cookie</h3>
<asp:Button ID="btnRetrieveCookie" runat="server" Text="Retrieve Cookie"
OnClick="btnRetrieveCookie_Click" />
<br /><br />

<h3>Delete Cookie</h3>
<asp:Button ID="btnDeleteCookie" runat="server" Text="Delete Cookie"
OnClick="btnDeleteCookie_Click" />
</div>
</form>
<h4>NAME: SANDESH</h4>
</body>
</html>

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

namespace New_Pract_7a
{
public partial class CookiesDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblMessage.Text = "";
}

// Create a session cookie (expires when browser is closed)


protected void btnCreateSessionCookie_Click(object sender, EventArgs e)
{
string cookieValue = txtCookieValue.Text;
HttpCookie sessionCookie = new HttpCookie("SessionCookie", cookieValue);
Response.Cookies.Add(sessionCookie);
lblMessage.Text = "Session Cookie created successfully.";
}

// Create a persistent cookie (expires in 30 days)


protected void btnCreatePersistentCookie_Click(object sender, EventArgs e)
{
string cookieValue = txtCookieValue.Text;
HttpCookie persistentCookie = new HttpCookie("PersistentCookie", cookieValue);
persistentCookie.Expires = DateTime.Now.AddDays(30); // Set expiration to 30 days
Response.Cookies.Add(persistentCookie);
lblMessage.Text = "Persistent Cookie created successfully.";
}

// Create a secure cookie (only sent over HTTPS)


protected void btnCreateSecureCookie_Click(object sender, EventArgs e)
{
string cookieValue = txtCookieValue.Text;
HttpCookie secureCookie = new HttpCookie("SecureCookie", cookieValue);
secureCookie.Secure = true; // Ensure it's sent only over HTTPS
Response.Cookies.Add(secureCookie);
lblMessage.Text = "Secure Cookie created successfully.";
}

// Retrieve cookie value


protected void btnRetrieveCookie_Click(object sender, EventArgs e)
{
if (Request.Cookies["SessionCookie"] != null)
{
lblMessage.Text = "Session Cookie: " + Request.Cookies["SessionCookie"].Value + "<br/>";
}

if (Request.Cookies["PersistentCookie"] != null)
{
lblMessage.Text += "Persistent Cookie: " + Request.Cookies["PersistentCookie"].Value +
"<br/>";
}

if (Request.Cookies["SecureCookie"] != null)
{
lblMessage.Text += "Secure Cookie: " + Request.Cookies["SecureCookie"].Value + "<br/>";
}
if (lblMessage.Text == "")
{
lblMessage.Text = "No cookies found.";
}
}

// Delete cookie
protected void btnDeleteCookie_Click(object sender, EventArgs e)
{
if (Request.Cookies["SessionCookie"] != null)
{
HttpCookie sessionCookie = new HttpCookie("SessionCookie");
sessionCookie.Expires = DateTime.Now.AddDays(-1); // Expire the cookie
Response.Cookies.Add(sessionCookie);
}

if (Request.Cookies["PersistentCookie"] != null)
{
HttpCookie persistentCookie = new HttpCookie("PersistentCookie");
persistentCookie.Expires = DateTime.Now.AddDays(-1); // Expire the cookie
Response.Cookies.Add(persistentCookie);
}

if (Request.Cookies["SecureCookie"] != null)
{
HttpCookie secureCookie = new HttpCookie("SecureCookie");
secureCookie.Expires = DateTime.Now.AddDays(-1); // Expire the cookie
Response.Cookies.Add(secureCookie);
}

lblMessage.Text = "All cookies have been deleted.";


}
}
}

Output:
Session Cookie creation:
Persistent Cookie creation:

Secure Cookie creation:


Retrieving Cookie:

Deleting Cookie:
Practical 7b

Aim: Create a web application to demonstrate Form Security and Windows Security with proper
Authentication and Authorization properties.

Design:

Code:

Output:
Practical 8a

Aim: Create a web application for inserting and deleting records from a database. (Using ExecuteNon
Query).

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract 8a.aspx.cs"
Inherits="Practical_8.Pract_8a" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 36%;
height: 111px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Employee ID"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Employee Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Employee Salary"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="Insert" OnClick="Button1_Click" />
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label5" runat="server"></asp:Label>
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connStr2 %>"
InsertCommand="INSERT INTO [Employee2] ([Eid], [Ename], [Esalary]) VALUES (@Eid,
@Ename, @Esalary)">
<InsertParameters>
<asp:Parameter Name="Eid" Type="Int32" />
<asp:Parameter Name="Ename" Type="String" />
<asp:Parameter Name="Esalary" Type="Decimal" />
</InsertParameters>
</asp:SqlDataSource>
<br />
<asp:Label ID="Label6" runat="server" Text="Select Employee Id:"></asp:Label>
&nbsp;<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="Eid"
DataValueField="Eid">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:connStr2 %>"
SelectCommand="SELECT Eid FROM Employee2">
</asp:SqlDataSource>
<br />
<br />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Delete" />
<br />
<br />
</div>
</form>
<h4>NAME: SANDESH</h4>
</body>
</html>

Code:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Practical_8
{
public partial class Pract_8a : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Optional: Bind the DropDownList on first load
if (!IsPostBack)
{
DropDownList1.DataBind();
}
}

protected void Button1_Click(object sender, EventArgs e)


{
// Validate TextBox inputs
if (string.IsNullOrEmpty(TextBox1.Text) || string.IsNullOrEmpty(TextBox2.Text) ||
string.IsNullOrEmpty(TextBox3.Text))
{
Label5.Text = "Please fill all fields.";
return;
}

// Set Insert Parameters


SqlDataSource1.InsertParameters["Eid"].DefaultValue = TextBox1.Text;
SqlDataSource1.InsertParameters["Ename"].DefaultValue = TextBox2.Text;
SqlDataSource1.InsertParameters["Esalary"].DefaultValue = TextBox3.Text;

// Execute Insert
try
{
SqlDataSource1.Insert();
Label5.Text = "Record added successfully";

DropDownList1.DataBind(); // Refresh the DropDownList


}
catch (Exception ex)
{
Label5.Text = "Error: " + ex.Message;
}
}

protected void Button2_Click(object sender, EventArgs e)


{
// Validate DropDownList selection
if (DropDownList1.SelectedValue == "")
{
Label5.Text = "Please select an employee to delete.";
return;
}

// Set Delete Command and execute


try
{
SqlDataSource1.DeleteCommand = "DELETE FROM Employee2 WHERE Eid = @Eid";
SqlDataSource1.DeleteParameters.Clear();
SqlDataSource1.DeleteParameters.Add("Eid", DropDownList1.SelectedItem.Value);
SqlDataSource1.Delete();

Label5.Text = "Record deleted successfully";


DropDownList1.DataBind(); // Refresh the DropDownList
}
catch (Exception ex)
{
Label5.Text = "Error: " + ex.Message;
}
}
}
}

Output:
Practical 8b

Aim: Create a web application for user defined exception handling.

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="New_Pract_8_b.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:Label ID="Label1" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
</div>
</form>

</body>
</html>

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

namespace New_Pract_8_b
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
// Throwing the custom exception
throw new UserDefinedException("New User Defined Exception");
}
catch (UserDefinedException ex) // Catching the custom exception
{
Label1.Text = "<b>Exception caught here: </b>" + ex.Message;
}
catch (Exception ex) // Catching any other exceptions
{
Label1.Text = "<b>Exception caught here: </b>" + ex.ToString();
}
// Final statement
Label2.Text = "Final Statement that is executed";
}

// Custom exception class


class UserDefinedException : Exception
{
public UserDefinedException(string message) : base(message)
{
// Optionally log the exception message or perform other actions
}
}
}
}

Output:
Practical 9a

Aim: Create a web application to demonstrate use of GridView button column and GridView events
along with paging and sorting.

Design & Code:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pract 9 a.aspx.cs"
Inherits="Practical_8.Pract_9_a" %>

<!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" CellPadding="4" DataKeyNames="EmployeeId"
DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" Height="283px"
Width="452px">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="EmployeeId" HeaderText="EmployeeId"
SortExpression="EmployeeId" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Esalary" HeaderText="Esalary" SortExpression="Esalary" />
</Columns>
<EditRowStyle BackColor="#999999" />
<EmptyDataTemplate>
No Record Found
</EmptyDataTemplate>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<PagerTemplate>
Pager Template
</PagerTemplate>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:connStr %>" SelectCommand="SELECT * FROM [Employee]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Output:
Practical 9b

Aim: Create a web application to demonstrate data binding using DetailsView and FormView Control

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PRACT 9 B.aspx.cs"
Inherits="Practical_8.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<!-- DetailsView Control -->
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateRows="False" DataKeyNames="EmployeeId">
<Fields>
<asp:BoundField DataField="EmployeeId" HeaderText="EmployeeId" InsertVisible="False"
ReadOnly="True" SortExpression="EmployeeId" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Esalary" HeaderText="Esalary" SortExpression="Esalary" />
</Fields>
</asp:DetailsView>
<br />

<!-- FormView Control -->


<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1"
DataKeyNames="EmployeeId" OnItemCommand="FormView1_ItemCommand" >
<EditItemTemplate>
EmployeeId:
<asp:Label ID="EmployeeIdLabel1" runat="server" Text='<%# Eval("EmployeeId") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
Esalary:
<asp:TextBox ID="EsalaryTextBox" runat="server" Text='<%# Bind("Esalary") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
&nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
Esalary:
<asp:TextBox ID="EsalaryTextBox" runat="server" Text='<%# Bind("Esalary") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
EmployeeId:
<asp:Label ID="EmployeeIdLabel" runat="server" Text='<%# Eval("EmployeeId") %>' />
<br />
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
<br />
Esalary:
<asp:Label ID="EsalaryLabel" runat="server" Text='<%# Eval("Esalary") %>' />
<br />
</ItemTemplate>
</asp:FormView>

<!-- SQL Data Source -->


<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connStr %>"
SelectCommand="SELECT * FROM [Employee]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>

Output:
Practical 10a
Aim: Create a web application to demonstrate JS Bootstrap Button.

Design & Code:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Bootstrap.aspx.cs"
Inherits="Pract10a.Bootstrap" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Bootstrap example</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<%--<link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"/>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js">
</script> --%>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/
tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-
IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-
cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF"
crossorigin="anonymous"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong>Bootsrap Button Styles in web Page<br />
<br />
</strong>
</div>
<asp:Button ID="Button1" runat="server" CssClass="btn-primary" Text=".btn-primary" />
<asp:Button ID="Button2" runat="server" CssClass="btn-warning" Text=".btn-warning" />
<br />
<br />
<asp:Button ID="Button4" runat="server" CssClass="btn-danger" Text=".btn-danger" Width="112px" />
<br />
<br />
<asp:Button ID="Button5" runat="server" CssClass="btn-primary disabled" Text=",btn-disabled" />
<asp:Button ID="Button6" runat="server" CssClass="btn-primary active" Text=".active" />
<br />
<br />
<asp:Button ID="Button7" runat="server" CssClass="btn-primary btn-lg" Text=".btn-lg" />
<asp:Button ID="Button8" runat="server" Text=".btn.xs" CssClass="btn-primary btn-xs" />
<br />
<br />
<asp:Button ID="Button9" runat="server" Text=".btn-block" CssClass="btn-primary btn-block" />
</form>
<h4>NAME: SAKET</h4>
</body>
</html>

Output:
Practical 10b
Aim: Create a web application to demonstrate use of various Ajax controls

Design:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pract 10 B.aspx.cs"
Inherits="Practical_10.pract_10_c" %>

<!DOCTYPE html>

<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 />
<h1 style="color:blueviolet">From Outside of Update Pannel:</h1>
<h3>It will refresh the whole page when the button gets pressed.</h3>
Enter The Name :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Get Name" />
<br />
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<h1 style="color:blueviolet">From Inside of Update Pannel:</h1> <br/>
<h3>It will refresh the only sub part of page when the button gets pressed.</h3>
Enter The Surname:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="1000"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
Please Wait ...
<br />
<asp:Image ID="Image1" runat="server" ImageUrl=”~image” />

</ProgressTemplate>
</asp:UpdateProgress>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Get Surname" />
<br>
</br>
<br />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
Time :
<asp:Label ID="Label3" runat="server"></asp:Label>
&nbsp;<asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick1">
</asp:Timer>
<br />
</ContentTemplate>
</asp:UpdatePanel>
<br />
</div>
</form>
<h4>NAME: SAKET</h4>
</body>
</html>

Output:
Practical 10c
Aim:

Design:

Code:

Output:

You might also like