AWP Practical New
AWP Practical New
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());
}
}
Output:
Practical 1.b
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());
Output:
Practical 1.c
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>
<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>
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/WebForm2.aspx">Test for prime
numbers.</asp:HyperLink>
<br />
</div>
</form>
</body>
</html>
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>
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>
<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)
{
namespace Pract1_d_
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Output
Home Page
WebForm1.aspx (Generate Fibonacci series.)
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;
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;
}
// Input numbers
Console.Write("Enter the first number: ");
int num1 = 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}");
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();
}
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" />
<asp:RadioButton ID="RadioButton2" runat="server" Text="SY" GroupName="Class" />
<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)
{
<!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>
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"));
}
}
}
<!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();
}*/
}
<!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>
<asp:TextBox ID="TextBox1" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Password Required"
ForeColor="Red">*</asp:RequiredFieldValidator>
<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>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<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>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<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>
<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"
%>
<!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">
</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> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="Button1" runat="server" Text="Submit" SkinID="Green" />
</td>
</tr>
</table>
<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"> </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);
}
}
}
}
}
}
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> </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)
{
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)
{
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>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
User Email:
<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)
{
Output:
Practical 6a
Aim: Create a web application for inserting and deleting records from a database.
<!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" />
<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" />
<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" />
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
<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=\"Web\
" /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 >"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<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)
{
}
}
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 = "";
}
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);
}
Output:
Session Cookie creation:
Persistent Cookie creation:
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> </td>
<td> </td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="Insert" OnClick="Button1_Click" />
</td>
<td> </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>
<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();
}
}
// Execute Insert
try
{
SqlDataSource1.Insert();
Label5.Text = "Record added successfully";
Output:
Practical 8b
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";
}
Output:
Practical 9a
Aim: Create a web application to demonstrate use of GridView button column and GridView events
along with paging and sorting.
<!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 />
Output:
Practical 10a
Aim: Create a web application to demonstrate JS Bootstrap Button.
<!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>
<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: