Professional Documents
Culture Documents
Awp Practical
Awp Practical
AIM: Design a web page that calculates addition, subtraction, multiplication, division also display colors
to result using radio buttons.
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_14.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<p>
</p>
<br />
<br />
</p>
<p>
</p>
</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;
namespace practical_no_14
{ }
protected void Button1_Click(object sender, EventArgs e)
TextBox3.Text = a.ToString();
TextBox3.Text = a.ToString(); }
TextBox3.Text = a.ToString(); }
TextBox3.Text = a.ToString(); }
{ TextBox3.ForeColor = System.Drawing.Color.Red; }
{ TextBox3.ForeColor = System.Drawing.Color.Blue; }
{ TextBox3.ForeColor = System.Drawing.Color.Green;
}
Output:
Practical No 15
AIM: Demonstrate the use of calendar control to perform the following tasks – a. display the message
and vacations in calendar control.
b. select day in calendar control using style dates.
c. difference between the two calendar dates
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_15.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:Calendar ID="Calendar1" runat="server"
OnSelectionChanged="Calendar1_SelectionChanged"
OnDayRender="Calendar1_DayRender" Font-Underline="True"></asp:Calendar>
<br/>
<asp:Calendar ID="Calendar2" runat="server" Font-Underline="True"></asp:Calendar>
<br/>
<asp:Button ID="Button1" runat="server" Text="ans " OnClick="Button1_Click"/>
<asp:Label ID="Label1" runat="server" Text="Label"></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;
namespace practical_no_15
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
Calendar1.SelectedDayStyle.BackColor = System.Drawing.Color.Yellow;
Calendar1.SelectedDayStyle.ForeColor = System.Drawing.Color.Red;
}
protected void Button1_Click(object sender, EventArgs e)
{
TimeSpan time = Calendar2.SelectedDate - Calendar1.SelectedDate;
Label1.Text = "answer is " + time.Days.ToString() + " Days"; }
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.Date.Year == 2022 && e.Day.Date.Month == 10 && e.Day.Date.Day == 10)
{ e.Cell.Controls.Add(new LiteralControl("<br>my birthday"));
}
}
}
}
Output:
Practical No 16
AIM: Design data entry screen for the student record. It should accept roll number, name, age, address
and email id mobile number, class, total marks, out of marks, password. It should calculate percentage
and grade also and add this record in the list box all the information entry compulsory. password should
be reconfirmed. age should be within 18 to 60 years, email id should be valid, mobile number must have
limit of 10 digit
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_16.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
&n
bsp;
<br />
<br />
&n
bsp;
<asp:TextBox ID="TextBox2" runat="server" Width="121px"></asp:TextBox>
<br />
<br />
&n
bsp;
<br />
<br />
&n
bsp;
<br />
<br />
&n
bsp;
<br />
<br />
ValidationExpression="^[6-9]\d{9}$"></asp:RegularExpressionValidator>
<br />
<br />
&n
bsp;
<br />
<br />
<br />
<br />
&n
bsp;
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:ListItem>name</asp:ListItem>
<asp:ListItem>rollno</asp:ListItem>
<asp:ListItem>percentage</asp:ListItem>
<asp:ListItem>grade</asp:ListItem>
</asp:ListBox>
<br />
<br />
<br />
<br />
<br />
<br />
</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;
namespace practical_no_16
grade = "A";
grade = "B";
grade = "C";
Label13.Text = per.ToString();
}
Output:
With valid details:
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_17.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Redirecting pages"></asp:Label>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Using Server.Transfer"></asp:Label>
:
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="WebForm2"
/>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Using Responce.Redirect"></asp:Label>
:
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click"
Text="WebForm2" />
<br />
</div>
<p>
</p>
<p>
</p>
</form>
</body>
</html>
WebForm2.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"
Inherits="practical_no_17.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<div style="margin-left: 120px">
<asp:Label ID="Label1" runat="server" Text="Welcome to
WebForm2.aspx"></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;
namespace practical_no_17
{
public partial class WebForm1 : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{} protected void Button1_Click(object sender, EventArgs e) =>
Server.Transfer("WebForm2.aspx");
protected void Button2_Click(object sender, EventArgs e)
{ Response.Redirect("WebForm2.aspx");
}
}
}
Output:
Using reponse.redirect
Using server.Transfer
Practical No 18a
AIM: Write a program to count no of times the current webpage is submitted to the server using OnClick
event of a button.
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_18a.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
</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;
namespace practical_no_18a
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
ViewState["count"] = 0;
}
}
AIM: Design a Webpage that displays a Welcome message to the user and also shows the number of
visitors to that webpage.
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_18b.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="welcome to my site "></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></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;
namespace practical_no_18b
{ Label2.Text = Application["visitor"].ToString(); } } }
Global.asax:
namespace practical_no_18b
{ Application["visitor"] = 0; }
{ Application.Lock();
Application["visitor"] = (int)Application["visitor"] + 1;
Application.UnLock();
{}
}}}
Output:
Practical No 19
AIM: Create a simple Webpage to show how to write and read from a client computer
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_19.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</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;
namespace practical_no_19
{}
{ Response.Cookies["user"].Value = TextBox1.Text;
Response.Cookies["password"].Value = TextBox2.Text;
Label3.Text = Request.Cookies["user"].Value;
Label4.Text = Request.Cookies["password"].Value;
}
Output:
Practical No 20
AIM: Design a webpage using checkbox and panel control. Place 2 textbox i.e., textbox1, textBox2 and a
button control inside a control panel, so that onclick event of this button the factorial of the value
provided in textbox1 will get displayed in textbox2, set the visible property of panel control to false.
Write the C# code to make the panel visible in the “OnCheckedChanged” event of checkbox so that the
factorial operation can be performed
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_20.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
<br />
<br />
</asp:Panel> </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;
namespace practical_no_20
if (CheckBox1.Checked)
{ Panel1.Visible = true; }
else
{ Panel1.Visible = false; }
int a = Convert.ToInt32(TextBox1.Text);
int fact = 1;
for (int i = a; i > 0; i--)
{ fact = fact * i; }
TextBox2.Text = fact.ToString(); } } }
Output:
Practical No 21a
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_21a.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
</div>
</form>
</body>
</html>
External.css:
body {
background-color:aqua;
*{
font-family:Arial;
color:magenta;
h1{
text-align:left;
color:green;
#TextBox1 {
color: yellow;
width: 100px;
background-color: silver;
.Label2{
color:brown;}
Output:
Practical No 21b
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="practical_no_19.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style>
body {
background-color:lightpink; }
*{
font-family:Broadway;
color:red; }
h1{
text-align:left;
color:blue; }
#TextBox1 {
color: aqua;
width: 100px;
background-color:rebeccapurple;
.Label2{
color:green; }
</style>
<title></title>
</head>
<body>
<div>
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Output:
Practical No 21c
CODE:
WebForm1.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="background-color:black;">
<div>
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Output:
Practical No 22
AIM: Create a simple webpage with various controls to demonstrate setting and use their property (eg.
AutoPostBack).
a. Onclick of button control display the selected item from the list box in a text box also in the same
webpage display the name of selected item from the drop-down list one from the drop down in label.
also change the font sizes of the same label according to the font size selected from the drop-down list
tool.
c. check box provides special formatting (like underline, bold, italic) and radio button provide colors for
labels
CODE:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="hitesh22.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<div>
<asp:ListItem>hitesh</asp:ListItem>
<asp:ListItem>omkar</asp:ListItem>
<asp:ListItem>tushar</asp:ListItem>
<asp:ListItem>vishal</asp:ListItem>
</asp:ListBox>
<p>
</p>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:ListItem>awp</asp:ListItem>
<asp:ListItem>spm</asp:ListItem>
<asp:ListItem>ngt</asp:ListItem>
</asp:DropDownList>
<br />
&n
bsp;
<br />
<br />
<asp:ListItem Value="20">1</asp:ListItem>
<asp:ListItem Value="15">2</asp:ListItem>
<asp:ListItem Value="10">3</asp:ListItem>
<asp:ListItem Value="5">4</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<br />
&n
bsp;
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
GroupName="parivartan" OnCheckedChanged="RadioButton1_CheckedChanged" Text="cyan" />
<p>
&n
bsp;
</p>
<p>
<br />
</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;
namespace practical_no_22
TextBox1.Text = ListBox1.SelectedValue.ToString();
{ Label1.Font.Bold = true; }
{ Label1.Font.Italic = true; }
{ Label1.Font.Underline = true; }
{ Label1.ForeColor = System.Drawing.Color.Cyan; }
{ Label1.ForeColor = System.Drawing.Color.Red; }
{ Label1.ForeColor = System.Drawing.Color.HotPink; }
{ Label1.Font.Size = Convert.ToInt32(DropDownList2.SelectedValue); }
{ Label1.Text = DropDownList1.SelectedValue.ToString();
}
Output:
Practical No 23
AIM: Create a webform to demonstrate use of add rotator control with 5 ads also demonstrate how
keyword filter works.
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="hitesh23.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
</form>
</body>
</html>
XMLFile1.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>pexels-elijah-o'donnell-3473569.jpg</ImageUrl>
<NavigateUrl>https://www.google.com</NavigateUrl>
<AlternateText>Ad 1</AlternateText>
<Impressions>20</Impressions>
<Keyword>ad1</Keyword>
<Height>300</Height>
<Width>500</Width>
</Ad>
<Ad>
<ImageUrl>hd-anime-nezuko-t5040jd8hqc0qrmq.jpg</ImageUrl>
<NavigateUrl>https://www.yahoo.com</NavigateUrl>
<AlternateText>Ad 2</AlternateText>
<Impressions>20</Impressions>
<Keyword>ad2</Keyword>
<Height>300</Height>
<Width>500</Width>
</Ad>
<Ad>
<ImageUrl>642268.jpg</ImageUrl>
<NavigateUrl>https://www.youtube.com</NavigateUrl>
<AlternateText>Ad 3</AlternateText>
<Impressions>20</Impressions>
<Keyword>ad3</Keyword>
<Height>300</Height>
<Width>500</Width>
</Ad>
<Ad>
<ImageUrl>197837.jpg</ImageUrl>
<NavigateUrl>https://www.facebook.com</NavigateUrl>
<AlternateText>Ad 4</AlternateText>
<Impressions>20</Impressions>
<Keyword>ad4</Keyword>
<Height>300</Height>
<Width>500</Width>
</Ad>
<Ad>
<ImageUrl>IMG_20180410_172754.jpg</ImageUrl>
<NavigateUrl>https://www.github.com</NavigateUrl>
<AlternateText>Ad 5</AlternateText>
<Impressions>20</Impressions>
<Keyword>ad5</Keyword>
<Height>300</Height>
<Width>500</Width>
</Ad>
</Advertisements>
Output:
Practical No 24
AIM: Create a web form to demonstrate use of user control. Create footer name user control having
reserved (ex: @CompanyName) and use it in a web form.
CODE:
WebUserControl1.ascx:
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="WebUserControl1.ascx.cs"
Inherits="practical_no_24.WebUserControl1" %>
<hr />
<h1>welcome to my web site </h1>
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_24.WebForm1" %
<%@ Register Src="~/WebUserControl1.ascx" TagPrefix="uc2"
TagName="WebUserControl1" %>
<!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="my first page
"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="web page 2"
OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="web page 3"
OnClick="Button2_Click" style="height: 29px" />
<uc2:WebUserControl1 runat="server" ID="WebUserControl1" />
</div>
</form>
</body>
</html>
WebForm2.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm2.aspx.cs" Inherits="practical_no_24.WebForm2" %>
<%@ Register Src="~/WebUserControl1.ascx" TagPrefix="uc1"
TagName="WebUserControl1" %>
<!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="my second page
"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="web page1"
OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="web page 3"
OnClick="Button2_Click" />
<uc1:WebUserControl1 runat="server" ID="WebUserControl1" />
</div>
</form>
</body>
</html>
WebForm3.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm3.aspx.cs" Inherits="practical_no_24.WebForm3" %>
AIM: Create a web application to demonstrate use of master page with applying styles and themes for
page beautificatication.
CODE:
MasterPage.master:
<%@ Master Language="C#" AutoEventWireup="true"
CodeBehind="Site1.master.cs" Inherits="practical_no_25.Site1" %>
WebUserControl1.ascx:
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="WebUserControl1.ascx.cs"
Inherits="practical_no_25.WebUserControl1" %>
<img src="HEADER.jpg" style="width:1600PX" />
Home.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"
Inherits="practical_no_25.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style>
body{
background-color:rosybrown;
}
pre{
text-align:center;
padding-left:40px;
font-family:Garamond;
font-size:28px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server"> &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp;
<br />
<pre>
<i> In 1839, the ability of some materials to create an electrical
charge from light exposure was first observed by the French physicist
Edmond Becquerel [1] Though these initial solar panels were too
inefficient for even simple electric devices, they were used as an
instrument to measure light.[2] The observation by Becquerel was not
replicated again until 1873, when the English electrical engineer
Willoughby Smith discovered that the charge could be caused by light
hitting selenium. After this discovery, William Grylls Adams and Richard
Evans Day published "The action of light on selenium" in 1876,
describing the experiment they used to replicate Smith's results.[1][3]
In 1881, the American inventor Charles Fritts created the first
commercial solar panel, which was reported by Fritts as "continuous,
constant and of considerable force not only by exposure to sunlight but
also to dim, diffused daylight."[4] However, these solar panels were
very inefficient, especially compared to coal-fired power plants. In
1939, Russell Ohl created the solar cell design that is used in many
modern solar panels. He patented his design in 1941.[5] In 1954, this
design was first used by Bell Labs to create the first commercially
viable silicon solar cell.[1] </i></pre>
</asp:Content>
History.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs"
Inherits="practical_no_25.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style>
body{
background-color:rosybrown; }
p{
font-family:Garamond;padding-left:10px;font-
size:35px;border-style:solid;border-width:5px;border-color:black }
h1{
text-align:center;color:teal;font-size:50px}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server"> &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp; &nb
sp;
<br />
<h1>HISTORY OF solarpanel</h1>
<p> <i> A solar cell panel, solar electric panel, photo
voltaic (PV) module or solar panel is an assembly of photovoltaic cells
mounted in a frame generating energy. Solar panels use sunlight as a
source of energy to generate direct current electricity. A collection of
PV modules is call panel, and a system of PV panels is called an array.
Arrays of a photovoltaic system supply solar electricity to electrical
equipment </p>
</asp:Content>
About us.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="WebForm6.aspx.cs"
Inherits="practical_no_25.WebForm6" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style>
body{
background-color:rosybrown;
}
h1,h2{
color:navy;letter-spacing:5px;text-
decoration:underline;text-align:center;font-size:50px
}
p{
margin:80px;list-style-type:square;font-
size:28px;color:green;font-family:Garamond
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<h1>GIVE YOUR RESPONSE</h1>
<asp:Label ID="Label1" runat="server" Text="name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="email"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="what you think in
upcoming years throwball can a part of olympic?"></asp:Label>
<br />
<asp:RadioButton ID="RadioButton1" runat="server" Text="yes" />
<br />
<asp:RadioButton ID="RadioButton2" runat="server" Text="no" />
<br />
<asp:Label ID="Label4" runat="server" Text="comments"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<br />
<br />
<hr style="color:black"/>
<h2>ABOUT US</h2>
<p> "History of TFI" Throwball Federation of India. Archived from the
original on December 1, 2008. Retrieved 2008-11-06.
"Rules and Regulations" Throwball Federation of India. Archived
from the original on December 1, 2008. Retrieved 2008-11-0</p>
</asp:Content>
Output:
Home.aspx:
History.aspx:
About us.aspx:
Practical No 26
AIM: Create a web application to display student’s data from the database using SQL source control
and bind it to grid view. Database fields are (roll no, name, class, mobile no, email-id)
Step 1 – file –> new –> website –> empty website –> Ok
Step 3 – Write click on table –> in server explorer –> add new table –> add columns –> click on update
Step 4 – Write click on table mode –> Click show table –> add values
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_26.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="rollno"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="rollno"
HeaderText="rollno" ReadOnly="True" SortExpression="rollno" />
<asp:BoundField DataField="name" HeaderText="name"
SortExpression="name" />
<asp:BoundField DataField="class" HeaderText="class"
SortExpression="class" />
<asp:BoundField DataField="phoneno"
HeaderText="phoneno" SortExpression="phoneno" />
<asp:BoundField DataField="emailid"
HeaderText="emailid" SortExpression="emailid" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Table]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Output:
Practical No 27
AIM: :Create a simple web page containing the student details (roll no, name, class, phone and email)
Write a program to store the data in database and retrieve using data reader
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_27.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="rollno"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label2" runat="server"
Text="name"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label3" runat="server"
Text="class"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="phone
no"></asp:Label>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label5" runat="server"
Text="emailid"></asp:Label>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="add data" />
<asp:Button ID="Button2" runat="server"
OnClick="Button2_Click" Text="read data" />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" >
</asp:GridView>
</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.SqlClient;
using System.Drawing;
namespace practical_no_27
{ public partial class WebForm1 : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{} protected void Button1_Click(object sender, EventArgs e)
{ SqlConnection conn = new SqlConnection(@"Data
Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1
.mdf;Integrated Security=True");
string str = "insert into Stud values(" + TextBox1.Text + ",
'" + TextBox2.Text + "', '" + TextBox3.Text + "', '" + TextBox4.Text +
"', '" + TextBox5.Text + "')";
SqlCommand cmd = new SqlCommand(str, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close(); }
protected void Button2_Click(object sender, EventArgs e)
{ SqlConnection conn = new SqlConnection(@"Data
Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Database1
.mdf;Integrated Security=True");
SqlCommand sc2 = new SqlCommand("select * from stud", conn);
conn.Open();
SqlDataReader xd = sc2.ExecuteReader();
GridView1.DataSource = xd;
GridView1.DataBind();
conn.Close();
}
}
}
Output:
Practical No 28
AIM: Create a simple web application to insert, update and delete data from a database
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_28.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="id"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br /> <br />
<asp:Label ID="Label2" runat="server"
Text="name"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label3" runat="server"
Text="class"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label4" runat="server"
Text="address"></asp:Label>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="insert" /> 
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click"
Text="update" />
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click"
Text="delete" />
<asp:Button ID="Button4" runat="server" OnClick="Button4_Click"
Text="show" />
<br />
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>
WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace practical_no_28
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new
SqlConnection(@"DataSource=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|Data
Directory|\Database.mdf;IntegratedSecurity=True");
String a = "insert into stud values (" + TextBox1.Text +
",'" + TextBox2.Text +
"','" + TextBox3.Text + "','" + TextBox4.Text + "')";
SqlCommand cmd = new SqlCommand(a, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection conn = new
SqlConnection(@"Dataource=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataD
irectory|\Database.mdf;IntegratedSecurity=True");
String a = "update stud set name = '" + TextBox2.Text + "',
class = '" +
TextBox3.Text + "', address = '" + TextBox4.Text + "' where
id = " + TextBox1.Text;
SqlCommand cmd = new SqlCommand(a, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
SqlConnection conn = new
SqlConnection(@"DataSource=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|Data
Directory|\Database.mdf;Integratedsecurity=True");
String a = "delete from stud id = " + TextBox1.Text;
SqlCommand cmd = new SqlCommand(a, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
SqlConnection conn = new
SqlConnection(@"DataSource=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|Data
Directory|\Database.mdf;Integrated Security=True");
SqlCommand a = new SqlCommand("select * from stud", conn);
conn.Open();
SqlDataReader sdr = a.ExecuteReader();
GridView1.DataSource = sdr;
GridView1.DataBind();
conn.Close();
}
}
}
Output:
Practical No 29
AIM: Write a program to save data in a xml file which user is going to insert from webform.
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_29.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="product
id"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br /> <br />
<asp:Label ID="Label2" runat="server" Text="product
name"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br /> <br />
<asp:Label ID="Label3" runat="server"
Text="quantity"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label4" runat="server"
Text="price"></asp:Label>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="submit" />
</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.Xml;
namespace practical_no_29
{public partial class WebForm1 : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{}
protected void Button1_Click(object sender, EventArgs e)
{ XmlTextWriter a = null;
string filepath = (Server.MapPath("~") + "\\XMLFile1.xml");
a = new XmlTextWriter(filepath, System.Text.Encoding.UTF8);
a.Formatting = Formatting.Indented;
a.WriteStartDocument();
a.WriteStartElement("Product");
a.WriteElementString("id", TextBox1.Text);
a.WriteElementString("Name", TextBox2.Text);
a.WriteElementString("Quantity", TextBox3.Text);
a.WriteElementString("Price", TextBox4.Text);
a.WriteEndElement();
a.WriteEndDocument();
a.Flush();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = ""; } } }
Output:
Practical No 30
AIM: Write a program to read an xml file in any of the asp.net control.
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_30.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<div> </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.Xml;
using System.Data;
namespace practical_no_30
{ public partial class WebForm1 : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{ DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/XMLFile1.xml"));
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind(); }}}
XMLFile1.xml:
<?xml version="1.0" encoding="utf-8" ?>
<details>
<product>
<id>1</id>
<name>rice</name>
<quantity>20</quantity>
<price>400</price>
</product>
<product>
<id>2</id>
<name>wheat</name>
<quantity>40</quantity>
<price>300</price>
</product>
<product>
<id>3</id>
<name>sugar</name>
<quantity>8</quantity>
<price>80000</price>
</product>
<product>
<id>4</id>
<name>salt</name>
<quantity>20</quantity>
<price>2000</price>
</product>
</details>
Output:
Practical No 31
AIM: Create an xml file to store records of 4 persons with name , age, address. Write a program to read
the details of the person whose age is less than 60, From the xml file and display it webpage uising
GridView control.
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_32.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
</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.Xml.Linq;
namespace practical_no_32
{ public partial class WebForm1 : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{ XDocument a =
XDocument.Load(Server.MapPath("~/XMLFile1.xml"));
var records = from b in a.Root.Elements("person")
where (Convert.ToInt32(b.Element("age").Value) < 60) select new
{ name = b.Element("name").Value,
age = b.Element("age").Value,
address = b.Element("address").Value, };
GridView1.DataSource = records;
GridView1.DataBind();
}
}
}
XmlFIle1.xml:
<?xml version="1.0" encoding="utf-8" ?>
<deatils>
<person>
<name>khushal</name>
<age>19</age>
<address>virar</address>
</person>
<person>
<name>hitesh</name>
<age>20</age>
<address>virar</address>
</person>
<person>
<name>prashik</name>
<age>19</age>
<address>Borivali</address>
</person>
<person>
<name>shubham</name>
<age>21</age>
<address>Gorai</address>
</person>
</deatils>
Output:
Practical No 32
AIM: Create a web page to demonstrate form security with proper authentication and authorization
properties
CODE:
login1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_31_32_.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="username"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<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="Button" />
<br />
<br />
<asp:Label ID="Label3" runat="server"
Text="Label"></asp:Label>
<br />
</div>
</form>
</body>
</html>
login1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace practical_no_31_32_
{ public partial class WebForm1 : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
if (FormsAuthentication.Authenticate(TextBox1.Text, TextBox2.Text))
{
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
}
else
{
Label3.Text = "Please Enter Correct Username and Password";
}
}
}
}
hello2.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm2.aspx.cs" Inherits="practical_no_31_32_.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:Label ID="Label1" runat="server"
Text="welcome"></asp:Label> </div>
</form>
</body>
</html>
Web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
<authentication mode="Forms">
<forms loginUrl="WebForm1.aspx" defaultUrl="WebForm2.aspx">
<credentials passwordFormat="Clear">
<user name="khush" password="1234"/>
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
Output:
Practical No 33
AIM: Create a simple web application to display time in textbox and when user click on show time
button at that time implement 2 second delay in between and within 2 second delay message wait for
some time (using AJAX control).
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_33.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>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Get Time"
OnClick="Button1_Click" />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Timer ID="Timer1" runat="server" Interval="2000" Enabled="false"
OnTick="Timer1_Tick">
</asp:Timer>
<br />
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</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;
namespace practical_no_33
{ public partial class WebForm1 : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{}
protected void Button1_Click(object sender, EventArgs e)
{ Label1.Text = "Please Wait for some time";
Timer1.Enabled = true; }
protected void Timer1_Tick(object sender, EventArgs e)
{ TextBox1.Text = DateTime.Now.ToString();
Label1.Text = "";
}
}
}
Output:
Practical No 34
AIM: Write a program to hide, show, toggle, slideup, slidedown the content on the respectively click
event using jquery.
CODE:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WebForm1.aspx.cs" Inherits="practical_no_34.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-3.4.1.min.js"></script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("p").hide();
});
});
$(document).ready(function(){
$("#show").click(function(){
$("p").show();
});
});
$(document).ready(function () {
$("#toggle").click(function () {
$("p").toggle();
});
});
$(document).ready(function () {
$("#flip").click(function () {
$("#panel").slideDown("slow")
});
});
$(document).ready(function () {
$("#panel").click(function () {
$("#panel").slideUp("slow")
});
});
</script>
<style>
#panel,#flip{
padding:5px;
text-align:center;
background-color:yellow;
border:solid 1px #c3c3c3;
}
#panel{
padding:50px;
display:none;
}}
</style>
</head>
<body>
<div>
<div id="flip"> click to slide down</div>
<div id ="panel"> hello world!</div>
<p> <b>This is a little para. </b><br/> </p>
<button id="hide">Hide</button>
<button id="show">Show</button>
<button id="toggle">toggle</button> </div>
</body>
</html>
Output:
Hide:
Show:
Toggle:
Slideup:
Slidedown: