Awd 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 47

1|Page

AWD

PRACTICAL
2|Page

1 Write the program for the following:

a. Create an application to print on screen the output of adding, subtracting,


multiplying and dividing two numbers entered by the user in C#.

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

namespace Practica1_a
{
internal class Program
{
static void Main(string[] args)
{
int num3 = 0;
Console.WriteLine("Enter a number: ");
int num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter b number: ");
int num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter choice \n 1-addition \n 2-Subtraction \n 3-Multiplication \n 4-Divide");
int choice=Convert.ToInt32(Console.ReadLine());

switch(choice)
{
case 1:
num3=num1+ num2;
Console.WriteLine("Sum of a and b is: " + num3);
break;
case 2:
num3=num1- num2;
Console.WriteLine("Subtraction of a and b is: " + num3);
break;
case 3:
num3 = num1* num2;
Console.WriteLine("Multiplication of a and b is: " + num3);
break;
case 4:
num3 = num1 / num2;
Console.WriteLine("dividing of a and b is: " + num3);
break;
default:
Console.WriteLine("Invalide choise..");
break;
3|Page

}
Console.ReadKey();

}
}
}
OUTPUT:

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

using System;
class Program
{
static void Main(string[] args)
{
int i,j,k=1;
for(i=1;i<=15; i++)
{
for(j=1;j<=i;j++)
{
Console.Write(k +" ");
k=k+1;
}
Console.Write("\n");
}
Console.ReadLine();
}
}
4|Page

Output:

c. Create an application to demonstrate following operations i.


Generate Fibonacci series. ii. Test for prime numbers.

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

namespace Practical1_C
{

public class Choice


{
public void Fiobonacci()
{
Console.WriteLine("Enter the number: ");
int n=Convert.ToInt32(Console.ReadLine());
5|Page

int n1=0, n2=1, n3;


for(int i=0; i<n; i++)
{
n3 = n1 + n2;
n1 = n2;
n2 = n3;
Console.Write(n3 + " ");
}
}
public void isPrime()
{
Console.WriteLine("Enter the number for checking is prime or not");
int num = Convert.ToInt32(Console.ReadLine());
int flag = 0;
for (int i = 2; i < num / 2; i++)
{
if (num % 2 == 0)
{
Console.WriteLine("Is not prime number");
flag = 1;
break;
}
}
if (flag == 0)
{
Console.WriteLine("is prime number");
}
}

}
internal class Program
{
static void Main(string[] args)
{
Choice c1 = new Choice();
bool iscontinue = true;
while(iscontinue)
{
Console.WriteLine("Enter choice to 1:generate fibonaccie and 2: check number prime");
int choice = Convert.ToInt32(Console.ReadLine());
if (choice == 1)
{
c1.Fiobonacci();
}
else if (choice == 2)
{
c1.isPrime();

}
else
{
6|Page

Console.WriteLine("please choice valide");


}

Console.WriteLine("\nDo you want to continue....:[Y/N]");


String userResponse= Console.ReadLine();
if(userResponse !="y" && userResponse !="Y")
{
iscontinue = false;
}

}
Console.WriteLine("Program existed ....");
}

}
}

OUTPUT:

2. Write the program for the following:

a. Create a simple application to demonstrate the concepts boxing and


unboxing.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
7|Page

using System.Threading.Tasks;

namespace prac2a
{
internal class Program
{
static void Main(string[] args)
{
int num = 100;
Object boxed = num;
Console.WriteLine("Boxed value: "+boxed);
int unboxed=(int)boxed;
Console.WriteLine("Unboxed value: " + unboxed);

num = 200;
Console.WriteLine("Origanal valaue after modification: " + num);
Console.WriteLine("Boxed value remain unchanged: " + boxed);

Console.ReadKey();
}
}
}

OUTPUT:

b. Create a simple application to perform addition and subtraction using


delegate.

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

namespace prac2b
{
public delegate int MathOperation(int x, int y );
internal class Program
8|Page

{
public static int Add(int a , int b)
{
return a + b;
}
public static int Subtract(int a , int b) { return a - b; }
static void Main(string[] args)
{
MathOperation operation = Add;
Console.WriteLine("\tAddition: "+operation(10,10));

operation=Subtract;
Console.WriteLine("\tSubtraction: "+operation(50,20));

Console.ReadKey();
}
}
}

OUTPUT:

c. Create a simple application to demonstrate use of the concepts of


interfaces.

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

namespace prac2c
{
interface abc
{
void Adding(int x, int y);
}
interface bcd
{
void show();
9|Page

class Test:abc,bcd
{
public void Adding(int a,int b)
{
Console.WriteLine("Addition is: "+(a + b));
}
public void show()
{
Console.WriteLine("show of test from abc");
}
}
internal class Program
{
static void Main(string[] args)
{
abc a1;
a1=new Test();
a1.Adding(10, 10);
bcd b1=(bcd)a1;
b1.show();
Console.ReadKey();
}
}
}

OUTPUT:

3 Write the program for the following:

a. Create a simple web page with various server controls to demonstrate


setting and use of their properties. (Example : AutoPostBack )

Register.aspx file

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="prac3a.Register"


%>
10 | P a g e

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<center>
<form id="form1" runat="server">
<div>
<h1>Registeration Form</h1>
<br />
<p>Name:&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p>
<p>Email Id:&nbsp;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</p>
<p>
Course:&nbsp;&nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</p>
<p>
Gender:&nbsp;&nbsp;&nbsp;
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="gender" Text="MALE" />
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="gender" Text="FEMALE" />

</p>
<p>
Esports:

<asp:CheckBox ID="CheckBox1" runat="server" Text="CLASH OF CLANS" />


<asp:CheckBox ID="CheckBox2" runat="server" Text="PUBG" />
<asp:CheckBox ID="CheckBox3" runat="server" Text="VALORANT" />
<asp:CheckBox ID="CheckBox4" runat="server" Text="CALL OF DUTY" />

</p>
<p>

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

</p>
<br />
<p>

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

</p>
<p>
11 | P a g e

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

</p>
<p>

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

</p>
<p>

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

</p>
<p>

<asp:Label ID="Label5" runat="server"></asp:Label>

</p>
</div>
</form>
<p>
&nbsp;</p>
</center>
</body>
</html>

Register.aspx.cs file:

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

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

protected void Button1_Click(object sender, EventArgs e)


{
String Name=TextBox1.Text;
String Email=TextBox2.Text;
String Course=TextBox3.Text;
String gender = "";
12 | P a g e

if (RadioButton1.Checked)
{
gender = RadioButton1.Text;
}
else
{
gender = RadioButton2.Text;
}

String Esports = "";


if (CheckBox1.Checked)
{
Esports=CheckBox1.Text;
}
if(CheckBox2.Checked)
{
Esports=CheckBox2.Text;
}
if (CheckBox3.Checked)
{
Esports=CheckBox3.Text;
}
if(CheckBox4.Checked)
{
Esports=CheckBox4.Text;
}

Label1.Text = "Your name is: " + Name;


Label2.Text="Email Id: "+Email;
Label3.Text="Course: "+Course;
Label4.Text = "Gender : " + gender;
Label5.Text = "Esports: " + Esports;

}
}
}

OUTPUT:
13 | P a g e

b. Create a simple application to demonstrate your vacation using calendar


control.

Calederform.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Calenderform.aspx.cs"


Inherits="Calenderform.Calenderform" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
14 | P a g e

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


<div>

<asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC" BorderColor="#FFCC66"


BorderWidth="1px" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="#663399" Height="200px" ShowGridLines="True" Width="602px"
OnDayRender="Calendar1_DayRender" OnSelectionChanged="Calendar1_SelectionChanged"
SelectedDate="10/12/2024 12:34:57">
<DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="#CC9966" />
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<SelectorStyle BackColor="#FFCC66" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt" ForeColor="#FFFFCC" />
<TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
</asp:Calendar>

<br />

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

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

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

Calenderform.aspx.cs

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

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

protected void Calendar1_SelectionChanged(object sender, EventArgs e)


15 | P a g e

{
Calendar1.SelectedDayStyle.BackColor = System.Drawing.Color.Yellow;
Calendar1.SelectedDayStyle.ForeColor= System.Drawing.Color.Green;

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)


{
if(e.Day.Date.Year==2024 && e.Day.Date.Month==8 && e.Day.Date.Day==15)
{
Label l1=new Label();
l1.Text = "<br>INDEPENDENCE DAY";
e.Cell.Controls.Add(l1);
}
if (e.Day.Date.Year == 2024 && e.Day.Date.Month == 10 && e.Day.Date.Day == 2)
{
Label l2 = new Label();
l2.Text = "<br>MAHATNA GANDHI JAYANTI";
e.Cell.Controls.Add(l2);
e.Cell.BackColor= System.Drawing.Color.Red;
}
}

protected void Button1_Click(object sender, EventArgs e)


{
Label1.Text = Calendar1.SelectedDate.ToString();
}
}
}

OUTPUT:
16 | P a g e

c. Demonstrate the use of Treeview operations on the web form.

TreeViewForm.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeviewForm.aspx.cs"


Inherits="prac3c.TreeviewForm" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows"


OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<Nodes>
<asp:TreeNode Text="Vikas College" Value="college">
<asp:TreeNode Text="BSC.CS" Value="BSC.CS">
<asp:TreeNode Text="TYCS" Value="TYCS"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="BSC.IT" Value="BSC.IT">
<asp:TreeNode Text="TYIT" Value="TYIT">
<asp:TreeNode Text="AWD" Value="AWD">
<asp:TreeNode Text="Prac1"Value="Prac1"></asp:TreeNode>
<asp:TreeNode Text="prac2" Value="prac2"></asp:TreeNode>
<asp:TreeNode Text="prac4" Value="prac4"></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>

</Nodes>
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px"
NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"
VerticalPadding="0px" />
</asp:TreeView>

<br />
&nbsp;<asp:TextBox ID="TextBox1" runat="server" style="margin-top: 0px" Width="466px"></asp:TextBox>

</div>
</form>
17 | P a g e

</body>
</html>

TreeViewForm.aspx.cs :

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

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

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)


{
TextBox1.Text="Selected Node: "+TreeView1.SelectedNode.Text.ToString().ToUpper();
}
}
}

OUTPUT:

4 Write the program for the following:


18 | P a g e

a. Create a Registration form to demonstrate use of various Validation controls.

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>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default
/nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008
/define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
</configuration>

ValidationForm.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidatorForm.aspx.cs"


Inherits="prac4a.ValidatorForm" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
19 | P a g e

<div>
<p>
Name: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please provide name"
ControlToValidate="TextBox1" ValidationGroup="a"></asp:RequiredFieldValidator>
</p>
<p>
Age:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox2"
ErrorMessage="Age between 17-25" MaximumValue="25" MinimumValue="17"
ValidationGroup="a"></asp:RangeValidator>
</p>
<p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add" ValidationGroup="a"
/>
</p>
<p>
<asp:Label ID="Label1" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="Label2" runat="server"></asp:Label>
</p>
</div>
</form>
</body>
</html>

ValidationForm.aspx.cs

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

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

protected void Button1_Click(object sender, EventArgs e)


{
Label1.Text="Welcome "+TextBox1.Text;
Label2.Text="Your Age is: "+TextBox2.Text;
20 | P a g e

}
}
}

OUTPUT:

b. Create Web Form to demonstrate use of Adrotator Control.

XMLFile1.xml

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


<Advertisements>
<Ad>
<ImageUrl>pizza.jpeg</ImageUrl>
<NavigateUrl>https://www.zomato.com/</NavigateUrl>
<AlternateText>
Pizza
</AlternateText>
<Impressions>20</Impressions>
<Keyword>pizza</Keyword>
</Ad>
<Ad>
<ImageUrl>burger.jpeg</ImageUrl>
<NavigateUrl>https://www.zomato.com/</NavigateUrl>
<AlternateText>
Burger
</AlternateText>
<Impressions>30</Impressions>
<Keyword>Burger</Keyword>
</Ad>
<Ad>
<ImageUrl>kfc.jpeg</ImageUrl>
<NavigateUrl>https://www.zomato.com/</NavigateUrl>
<AlternateText>
KFC
</AlternateText>
21 | P a g e

<Impressions>20</Impressions>
<Keyword>KFC</Keyword>
</Ad>
</Advertisements>

Ads.aspx file:

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" Height="300px"


Width="300px"/>

<%-- --%>
<br />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/XMLFile1.xml"></asp:XmlDataSource>
</div>
</form>
</body>
</html>

OUTPUT:
22 | P a g e

c. Create Web Form to demonstrate use User Controls

WebUserControl1.ascx file:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs"
Inherits="prac4c1.WebUserControl1" %>
<div>

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


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
23 | P a g e

<br />
<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Register" />
<asp:Label ID="Label3" runat="server"></asp:Label>

</div>

WebForm1.aspx file:

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


Inherits="prac4c1.WebForm1" %>

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<uc1:WebUserControl1 ID="WebUserControl11" runat="server" />
<div>

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

OUTPUT:

5 Write the program for the following:

a. Create Web Form to demonstrate use of Website Navigation controls.


24 | P a g e

Web.sitemap:

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


<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Home.aspx" title="Home page1" description="">
<siteMapNode url="~/admin/admin.aspx" title="admin page" description="" />
<siteMapNode url="~/staff/staffHome.aspx" title="staff home" description="" >
<siteMapNode url="~/staff/addStudent.aspx" title="add student" description=""/>
</siteMapNode>
<siteMapNode url="~/students/studentHome.aspx" title="student home" description="">
<siteMapNode url="~/students/exam.aspx" title="exam page" description="">
<siteMapNode url="~/students/result.aspx" title="result page" description=""/>
</siteMapNode>
</siteMapNode>
</siteMapNode>
</siteMap>

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

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" Font-Size="0.8em"
PathSeparator=" : ">
<CurrentNodeStyle ForeColor="#333333" />
<NodeStyle Font-Bold="True" ForeColor="#990000" />
<PathSeparatorStyle Font-Bold="True" ForeColor="#990000" />
<RootNodeStyle Font-Bold="True" ForeColor="#FF8000" />
</asp:SiteMapPath>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</div>
</form>
</body>
</html>

Web.config
25 | P a g e

<?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>
<siteMap>
<providers>
<remove name="MySqlSiteMapProvider"/>
</providers>
</siteMap>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default
/nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008
/define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>
</configuration>

Home.aspx :

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"


CodeBehind="Home.aspx.cs" Inherits="Practical5A.Home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>This is my home page</h1>
<p>
<asp:HyperLink ID="HyperLink1" runat="server" ForeColor="#663300"
NavigateUrl="~/admin/admin.aspx">Admin</asp:HyperLink>
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:HyperLink ID="HyperLink2" runat="server" ForeColor="Aqua"
NavigateUrl="~/staff/staffHome.aspx">Staff</asp:HyperLink>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:HyperLink ID="HyperLink3" runat="server" ForeColor="#FF6600"
NavigateUrl="~/students/studentHome.aspx">Students</asp:HyperLink>
26 | P a g e

</p>
</asp:Content>

OUTPUT:

b. Create a web application to demonstrate use of Master Page and content page.

Site1.master

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs"


Inherits="practical5B.Site1" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="~/css/StyleSheet1.css" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<header id="header">
<h1>Learning</h1>
</header>
<nav id="nav">
<span>Logo</span>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Artical</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<div id="con">
<div id="content">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
27 | P a g e

</div>
<aside>
<p><a href="#">news</a></p>
<p><a href="#">news</a></p>
<p><a href="#">news</a></p>
<p><a href="#">news</a></p>
</aside>
</div>
<footer>
<p>@CopyRight</p>
</footer>
</div>
</form>
</body>
</html>

WebForm1.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"


CodeBehind="WebForm1.aspx.cs" Inherits="practical5B.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>this is my child master page</h1>
<p>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/WebForm2.aspx">second master
page</asp:HyperLink>
</p>
</asp:Content>

OUTPUT:

c. Create a web application to demonstrate various states of ASP.NET Pages.


28 | P a g e

Webform2.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"


Inherits="Practical6.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</div>
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body>
</html>

WebForm2.aspx.cs

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

namespace Practical6
{
public partial class WebForm2 : System.Web.UI.Page
{
int x = 0;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
ViewState.Add("myx",x);
}

protected void Button1_Click(object sender, EventArgs e)


{
x = int.Parse(ViewState["myx"].ToString());
x++;
Label1.Text="You page refreshed "+ x.ToString()+" Times";
ViewState["myx"]= x;
29 | P a g e

}
}
}

OUTPUT:

6 .Write the program for the following:

a. Create a web application for inserting and deleting records from a database.

WebForm1.aspx:

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


Inherits="InsertandDelete.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="new Author" OnClick="Button1_Click" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" Text="remove Author" OnClick="Button2_Click" />
30 | P a g e

<br />
<br />
<asp:MultiView ID="MultiView1" runat="server">

<asp:View ID="View1" runat="server">


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

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server" TextMode="Number"
Width="340px"></asp:TextBox>

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


ControlToValidate="TextBox1" ErrorMessage="*" ValidationGroup="a"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Author Name"></asp:Label>
&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server" MaxLength="50" Width="334px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox2" ErrorMessage="*" ValidationGroup="a"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Phone Number"></asp:Label>
&nbsp;&nbsp;
<asp:TextBox ID="TextBox3" runat="server" MaxLength="10" Width="321px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" Display="Dynamic"
ErrorMessage="*" ValidationGroup="a" ControlToValidate="TextBox3"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox3" ErrorMessage="invalide number" ValidationExpression="\d{10}"
ValidationGroup="a"></asp:RegularExpressionValidator>
<br />
<br />
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Insert"
ValidationGroup="a" />
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label4" runat="server"></asp:Label>

</asp:View>
<asp:View ID="View2" runat="server">
<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" Width="202px">
</asp:DropDownList>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label5" runat="server"></asp:Label>
<br />
<br />
<asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="Delete" />
&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label6" runat="server"></asp:Label>
31 | P a g e

</asp:View>
</asp:MultiView>

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

WebForm1.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

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

protected void Button1_Click(object sender, EventArgs e)


{
MultiView1.SetActiveView(View1);
}

protected void Button2_Click(object sender, EventArgs e)


{
MultiView1.SetActiveView(View2);
updateDropdownList();
Label5.Text = "";
Label6.Text = "";
}

protected void Button3_Click(object sender, EventArgs e)


{
try
{
SqlConnection conn = new
SqlConnection(WebConfigurationManager.ConnectionStrings["c1"].ConnectionString);
conn.Open();
32 | P a g e

SqlCommand cmd = new SqlCommand("insert into Authors values(@id,@name,@phone)", conn);


cmd.Parameters.AddWithValue("@id", TextBox1.Text);
cmd.Parameters.AddWithValue("@name", TextBox2.Text);
cmd.Parameters.AddWithValue("@phone", TextBox3.Text);
cmd.ExecuteNonQuery();
Label4.Text = "Record is added successfully";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
conn.Close();
updateDropdownList();

}
catch (Exception ex)
{
Label4.Text = ex.Message;
}
}

protected void Button4_Click(object sender, EventArgs e)


{
try {
SqlConnection con = new
SqlConnection(WebConfigurationManager.ConnectionStrings["c1"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("delete from Authors where Auid=@id", con);
cmd.Parameters.AddWithValue("@id", DropDownList1.SelectedItem.Text);
cmd.ExecuteNonQuery ();
con.Close();
Label6.Text = "record deleted successfully";
updateDropdownList ();
Label5.Text = "";
}
catch(Exception ex) { Label6.Text = ex.Message; }
}
public void updateDropdownList()
{
try
{
SqlConnection con = new
SqlConnection(WebConfigurationManager.ConnectionStrings["c1"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select * from Authors", con);
SqlDataReader dr= cmd.ExecuteReader();
DropDownList1.DataSource = dr;
DropDownList1.DataTextField = "Auid";
DropDownList1.DataValueField = "Auname";
DropDownList1.DataBind();
con.Close();
}
catch (SqlException ex)
33 | P a g e

{
throw ex;
}
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{
Label5.Text = "Selected Author is " + DropDownList1.SelectedValue;
}
}
}

OUTPUT:

b. Create a web application to display Using Disconnected Data Access and


Databinding using GridView.

WebForm1.aspx

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


Inherits="prac6b.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
34 | P a g e

<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Employee Salary &gt;"></asp:Label>
&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server" TextMode="Number"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="*" ValidationGroup="a"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Show Data"
ValidationGroup="a" Width="243px" />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#CC9966"
BorderStyle="None" BorderWidth="1px" CellPadding="4">
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<SortedAscendingCellStyle BackColor="#FEFCEB" />
<SortedAscendingHeaderStyle BackColor="#AF0101" />
<SortedDescendingCellStyle BackColor="#F6F0C0" />
<SortedDescendingHeaderStyle BackColor="#7E0000" />
</asp:GridView>
<br />
<asp:Label ID="Label2" runat="server"></asp:Label>
</div>
</form>
</body>
</html>

WebForm1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

namespace prac6b
{
35 | P a g e

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


{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
try {
SqlConnection con = new
SqlConnection(WebConfigurationManager.ConnectionStrings["c1"].ConnectionString);
con.Open();
String sql = "select * from Employee where Esalary>" + TextBox1.Text;
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);

GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
con.Close();
}
catch (Exception ex)
{
Label2.Text= ex.Message;
}
}
}
}

OUTPUT:

8.Write the program for the following:


36 | P a g e

a. Create a web application for inserting and deleting records from a database. (Using
Execute-Non Query).

WebForm1.aspx:

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


Inherits="InsertandDelete.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="new Author" OnClick="Button1_Click" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button2" runat="server" Text="remove Author" OnClick="Button2_Click" />
<br />
<br />
<asp:MultiView ID="MultiView1" runat="server">

<asp:View ID="View1" runat="server">


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

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server" TextMode="Number"
Width="340px"></asp:TextBox>

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


ControlToValidate="TextBox1" ErrorMessage="*" ValidationGroup="a"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Author Name"></asp:Label>
&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server" MaxLength="50" Width="334px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox2" ErrorMessage="*" ValidationGroup="a"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Phone Number"></asp:Label>
&nbsp;&nbsp;
<asp:TextBox ID="TextBox3" runat="server" MaxLength="10" Width="321px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" Display="Dynamic"
ErrorMessage="*" ValidationGroup="a" ControlToValidate="TextBox3"></asp:RequiredFieldValidator>
37 | P a g e

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


ControlToValidate="TextBox3" ErrorMessage="invalide number" ValidationExpression="\d{10}"
ValidationGroup="a"></asp:RegularExpressionValidator>
<br />
<br />
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Insert"
ValidationGroup="a" />
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label4" runat="server"></asp:Label>

</asp:View>
<asp:View ID="View2" runat="server">
<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" Width="202px">
</asp:DropDownList>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label5" runat="server"></asp:Label>
<br />
<br />
<asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="Delete" />
&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label6" runat="server"></asp:Label>
</asp:View>
</asp:MultiView>

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

WebForm1.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

namespace InsertandDelete
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
38 | P a g e

protected void Button1_Click(object sender, EventArgs e)


{
MultiView1.SetActiveView(View1);
}

protected void Button2_Click(object sender, EventArgs e)


{
MultiView1.SetActiveView(View2);
updateDropdownList();
Label5.Text = "";
Label6.Text = "";
}

protected void Button3_Click(object sender, EventArgs e)


{
try
{
SqlConnection conn = new
SqlConnection(WebConfigurationManager.ConnectionStrings["c1"].ConnectionString);
conn.Open();
SqlCommand cmd = new SqlCommand("insert into Authors values(@id,@name,@phone)", conn);
cmd.Parameters.AddWithValue("@id", TextBox1.Text);
cmd.Parameters.AddWithValue("@name", TextBox2.Text);
cmd.Parameters.AddWithValue("@phone", TextBox3.Text);
cmd.ExecuteNonQuery();
Label4.Text = "Record is added successfully";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
conn.Close();
updateDropdownList();

}
catch (Exception ex)
{
Label4.Text = ex.Message;
}
}

protected void Button4_Click(object sender, EventArgs e)


{
try {
SqlConnection con = new
SqlConnection(WebConfigurationManager.ConnectionStrings["c1"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("delete from Authors where Auid=@id", con);
cmd.Parameters.AddWithValue("@id", DropDownList1.SelectedItem.Text);
cmd.ExecuteNonQuery ();
39 | P a g e

con.Close();
Label6.Text = "record deleted successfully";
updateDropdownList ();
Label5.Text = "";
}
catch(Exception ex) { Label6.Text = ex.Message; }
}
public void updateDropdownList()
{
try
{
SqlConnection con = new
SqlConnection(WebConfigurationManager.ConnectionStrings["c1"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select * from Authors", con);
SqlDataReader dr= cmd.ExecuteReader();
DropDownList1.DataSource = dr;
DropDownList1.DataTextField = "Auid";
DropDownList1.DataValueField = "Auname";
DropDownList1.DataBind();
con.Close();
}
catch (SqlException ex)
{
throw ex;
}
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{
Label5.Text = "Selected Author is " + DropDownList1.SelectedValue;
}
}
}

b. Create a web application for user defined exception handling.

NumberTooLargeException.cs :

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

namespace prac8b
{
public class NumberTooLargeException : Exception
{
public NumberTooLargeException():base() { }
40 | P a g e

public NumberTooLargeException(string message) : base(message) { }


public NumberTooLargeException(String message, Exception innerException) : base(message,
innerException) { }
}
}

WebForm1.aspx.cs:

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

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

protected void Button1_Click(object sender, EventArgs e)


{
try {
int number=int.Parse(TextBox1.Text);
if(number>100)
{
throw new NumberTooLargeException("The number entered too large please enter valide
number");
}
Label2.Text = "Number is valide";
}
catch (NumberTooLargeException ex)
{
Label2.Text = "Custome Error: "+ex.Message;

}
catch(FormatException ex)
{
Label2.Text= "Format Exception "+ex.Message;
}
catch (Exception ex) { }

}
}
}
41 | P a g e

WebForm1.aspx:

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


Inherits="prac8b.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>Input Number (must be less than or equaal to 100)</h2>
<asp:Label ID="Label1" runat="server" Text="Enter Number"></asp:Label>
&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<br />
<br />
<asp:Label ID="Label2" runat="server"></asp:Label>
</div>
</form>
</body>
</html>

OUTPUT:

10 Write the program for the following:

a. Create a web application to demonstrate JS Bootstrap Button.


42 | P a g e

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"/>

<title></title>
<script type="text/javascript">
function showAlert() {
alert("Bootstrap button Clicked");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<h2>Bootstrap Button</h2>
<br />
<button type="button" class="btn btn-primary" onclick="showAlert()">Click me!</button>
</div>
<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>

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

OUTPUT:
43 | P a g e

b. Create a web application to demonstrate use of various Ajax controls.

WebForm1.aspx:

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


Inherits="prac10b.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:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
&nbsp;
<asp:Label ID="Label3" runat="server" Text="Name"></asp:Label>
&nbsp;&nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
Password&nbsp;
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Login" Width="308px"
/>
<br />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
44 | P a g e

<br />
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"
DisplayAfter="1500">
<ProgressTemplate>
plz wait...<br />
<asp:Image ID="Image1" runat="server" ImageUrl="~/loading.gif" Width="182px" />
<br />
</ProgressTemplate>
</asp:UpdateProgress>
<br />
</form>
</body>
</html>

WebFrom1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button1_Click(object sender, EventArgs e)


{
System.Threading.Thread.Sleep(5000);
Label1.Text = "Login Successfully...";
}

}
}

OUTPUT:
45 | P a g e

c. Create a web application to demonstrate Installation and use of NuGet


package.

Install the NuGet Package:

1. Right-click on project in Solution Explore


2. Select Manage NuGet Packages.
3. In the Browse tab, search for Newtonsoft.json
4. Select the Newtonsoft.json package and install
5. After installation , the package will be added to your project’s
References
46 | P a g e

WebForm1.aspx:

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


Inherits="prac10c.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>NuGet Application</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Simple NuGet Application</h2>

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Serialize Object to Json" />


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

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

WebFrom1.aspx.cs:

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

namespace prac10c
{
public partial class WebForm1 : System.Web.UI.Page
{

public class SimplePerson


{
public String Name { get; set; }
public int Age { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
47 | P a g e

protected void Button1_Click(object sender, EventArgs e)


{
SimplePerson person = new SimplePerson
{
Name = "Suraj",
Age = 20
};
String json=JsonConvert.SerializeObject(person);

Label1.Text = "Serialized JSON: " + json;


}
}
}

OUTPUT:

You might also like