6417 - Sudesh Rajbhar - AWP
6417 - Sudesh Rajbhar - AWP
6417 - Sudesh Rajbhar - AWP
2023 - 2024
Certificate
1)A)Create an application that obtains four int values from the user and displays the
product.
Source code:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num1, num2, num3, num4, prod,sum;
Console.Write("Enter number 1: ");
num1 = Int32.Parse(Console.ReadLine());
Console.Write("Enter number 2: ");
num2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter number 3: ");
num3 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter number 4: ");
num4 = Convert.ToInt32(Console.ReadLine());
prod = num1 * num2 * num3 * num4;
sum= num1+ num2 +num3+num4;
Console.WriteLine(num1 + "*" + num2 + "*" + num3 + "*" + num4 + "=" + prod);
Console.WriteLine(num1 + "+" + num2 + "+" + num3 + "+" + num4 + "=" +
sum);
Console.ReadLine(); }
}
}
Output:
A)Using LOOP.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter Your Name ");
String s = Console.ReadLine();
Console.WriteLine("To print Length of String = " + s.Length);
Console.WriteLine("To Print Lower Case = " + s.ToLower());
Console.WriteLine("To Print in Upper Case = " + s.ToUpper());
Console.WriteLine("To Insert the Element = " + s.Insert(9, "10"));
Console.WriteLine("To Replace The Element = " + s.Replace("y", "i"));
String s2 = String.Concat("TYIT_AWP 6417");
Console.WriteLine("Concatenate the string with TYIT_AWP_6417" + s);
Console.ReadLine();
}
}
}
Output:
1)C)Create an application that receives the (Student Id, Student Name, Course Name,
Date of Birth) information from a set of students. The application should also display the
information of all the students once the data entered.
Source Code:
using System;
namespace ArrayOfStructs
{
class Program
{
struct Student
{
public string studid, name, cname;
public int day, month, year;
}
static void Main(string[] args)
{
Student[] s = new Student[5];
int i;
for (i = 0; i < 5; i++)
{
Console.Write("Enter Student Id:");
s[i].studid = Console.ReadLine();
Console.Write("Enter Student name : ");
s[i].name = Console.ReadLine();
Console.Write("Enter Course name : ");
s[i].cname = Console.ReadLine();
Console.Write("Enter date of birth\n Enter day(1-31):");
s[i].day = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter month(1-12):");
s[i].month = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter year:");
s[i].year = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("\n\nStudent's List\n");
for (i = 0; i < 5; i++)
{
Console.WriteLine("\nStudent ID : " + s[i].studid);
Console.WriteLine("\nStudent name : " + s[i].name);
Console.WriteLine("\nCourse name : " + s[i].cname);
Console.WriteLine("\nDate of birth(dd-mm-yy) : " + s[i].day + "-" + s[i].month +
"-" + s[i].year);
PRACTICAL NO 2: Working with Object Oriented C# and ASP .NET
2)A)i)Factorial
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Factorial
{
public static void Main(string[] args)
{
int i,fact=1,number;
Console.Write("Enter any Number: ");
number = int.Parse(Console.ReadLine());
for (i = 1; i <= number; i++)
{
fact = fact * i;
}
Console.Write("Factorial of " + number + " is: " + fact);
Console.ReadLine();
}
}
Output:
2)A)ii)Currency Converter
Source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CurrencyConverter
{
class Program
{
static void Main(string[] args)
{
double inr, usd, exchangeRate;
if (choice == 1)
{
// Convert INR to USD
Console.Write("Enter the amount in INR: ");
inr = double.Parse(Console.ReadLine());
Console.ReadLine();
}
}
}
Output:
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Currency
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the Currency in INR ");
double currency = Double.Parse(Console.ReadLine());
Console.WriteLine("1.USD " + "\n" + "2.EUR " + "\n");
while(true)
{
double currency1;
Console.WriteLine("Enter your choice");
String Choice= Console.ReadLine();
if(Choice=="USD")
{
currency1 = currency * 0.013;
Console.WriteLine(currency1);
}
else if(Choice=="EURO")
{
currency1 = currency * 0.012;
Console.WriteLine(currency1);
}
else if(Choice!="USD"||Choice!="EURO")
{
Console.WriteLine("hAVE YOU TYPED WRONG ,TYPE AGAIN:");
continue;
}
Console.WriteLine("do you wish to continue");
String s = Console.ReadLine();
if (s=="yes"&& s=="YES")
{
continue;
}
else if(s=="no"&& s=="NO")
{
break;
} } } }}
Output:
2)A)iii)Quadratic equation.
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
internal class Program
{
}
}
}
Output:
2)A)iv)Temperature Converter
Source Code:
using System;
class TemperatureConverter
{
static void Main()
{
Console.WriteLine("Temperature Conversion:");
Console.WriteLine("1. Celsius to Fahrenheit");
Console.WriteLine("2. Fahrenheit to Celsius");
Console.Write("Enter your choice (1 or 2): ");
int choice = Convert.ToInt32(Console.ReadLine());
if (choice == 1)
{
Console.Write("Enter the temperature in Celsius: ");
double celsius = Convert.ToDouble(Console.ReadLine());
double fahrenheit = CelsiusToFahrenheit(celsius);
Console.WriteLine("Temperature in Fahrenheit: " + fahrenheit);
}
else if (choice == 2)
{
Console.Write("Enter the temperature in Fahrenheit: ");
double fahrenheit = Convert.ToDouble(Console.ReadLine());
double celsius = FahrenheitToCelsius(fahrenheit);
Console.WriteLine("Temperature in Celsius: " + celsius);
}
else
{
Console.WriteLine("Invalid choice. Please enter 1 or 2.");
}
Console.ReadLine();
}
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Output:
2)B)ii) INHERITANCES.
● Single inheritance:
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Inheritance
{
class Program
{
static void Main(string[] args)
{
Teacher d = new Teacher();
d.Teach();
Student s = new Student();
s.Learn();
s.Teach();
Console.ReadKey();
}
class Teacher
{
public void Teach()
{
Console.WriteLine("Teach");
}
}
class Student : Teacher
{
public void Learn()
{
Console.WriteLine("Learn");
}
}
}
}
oUTPUT:
● Multilevel Inheritance.
using System;
namespace Practical2
{
class A
{
public void funcA()
{
Console.WriteLine("Class A Function is invoked");
}
}
class B : A
{
public void funcB()
{
Console.WriteLine("Class B Function is invoked");
}
}
class C : B
{
public void funcC()
{
Console.WriteLine("Class C Function is invoked");
}
}
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{ class A
{
public void a()
{
Console.WriteLine("Method a() from class A called..");
}}
class B : A
{
public void b()
{
a();
Console.WriteLine("Method b() from class B called..");
}}
class C : A
{
public void c()
{
a();
Console.WriteLine("Method c() from class C called..");
}}
internal class Program
{
static void Main(string[] args)
{ C c_obj = new C();
Console.WriteLine("hierarchical inheritance");
c_obj.c();
Console.ReadLine();
}}}
● Multiple Inheritance.
Source code:
using System;
namespace MultipleInheritance
{class Program
{
static void Main(string[] args)
{MultipleInheritanceTest obj = new MultipleInheritanceTest();
obj.Test();
Interface1 i1 = obj;
i1.Show();
((Interface2)obj).Show();
Console.ReadKey();
}}
void Interface1.Show()
{Console.WriteLine("Interface1 Show Method is Implemented in Child Class");
}
void Interface2.Show()
{
Console.WriteLine("Interface2 Show Method is Implemented in Child Class");
} }}
2)B)iii)Constructor Overloading.
Source Code:
using System;
public Person()
{
name = "Unknown";
age = 0;
}
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Inheritance
{
internal class Program
{
class A
{
public void a()
{
Console.WriteLine("Method a() from class A called..");
}
}
interface B
{
void b();
}
class C : A,B
{
public void c()
{
Console.WriteLine("Method c() from class C called..");
}
public void b()
{
Console.WriteLine("Method b() from class B called..");
}
}
static void Main(string[] args)
{
C obj_c = new C();
Console.WriteLine("Multiple Inheritance..\n");
obj_c.c();
obj_c.b();
Console.ReadLine();
}
}
}
2)C)i)Using Delegates and Events.
Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp4
{
internal class Program
{
objsum(num1, num2);
objsub(num1, num2);
Console.ReadLine();
}
}
}
Output:
2)C)ii) Exception handling
Source Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp4
{
internal class Program
{
}
catch (ArithmeticException e)
{
Console.WriteLine("Can Not Devide By Zero..");
}
Console.ReadLine();
}
}
}
PRACTICAL NO 3: Working with Web Forms and Controls
3)A)Create a simple web page with various server controls to demonstrate setting and
use of their properties. (Example: AutoPostBack)
Source code:
.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body id="Name">
<form id="form1" runat="server">
<div>
Student Registation Form_6417<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="NAME"></asp:Label>
<asp:TextBox ID="NAME_TB" runat="server"
> <br />
<asp:Label ID="Label2" runat="server" Text="ROLL NO"></asp:Label>
<asp:TextBox ID="ROLLNO_TB" runat="server"
> <br />
<asp:Label ID="Label3" runat="server" Text="SECTION"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<br />
Language Known<asp:RadioButtonList ID="lung_RBL" runat="server">
<asp:ListItem>Java</asp:ListItem>
<asp:ListItem>Python</asp:ListItem>
<asp:ListItem>C++</asp:ListItem>
</asp:RadioButtonList>
<br />
<br />
Course <asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>BSC-IT</asp:ListItem>
</asp:DropDownList>
<br />
<br />
Student Information:<br />
<br />
<asp:Label ID="Name_lbl" runat="server"></asp:Label>
<br />
<asp:Label ID="Roll_lbl" runat="server"></asp:Label>
<br />
<asp:Label ID="Section_lbl" runat="server"></asp:Label>
<br />
<asp:Label ID="Lang_lbl" runat="server"></asp:Label>
<br />
<asp:Label ID="Course_lbl" runat="server"></asp:Label>
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Sumit" />
</div>
</form>
</body>
</html>
Aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac3
{
public partial class webform1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Design:
3)B)Demonstrate the use of Calendar control to perform following operations.
a) Display messages in a calendar control
b) Display vacation in a calendar control
c) Selected day in a calendar control using style
d) Difference between two calendar dates
webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication_CalendarControl.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"
> > </div>
<br />
Today's Date: <asp:Label ID="Today_lb" runat="server"
Text="Today_Label"></asp:Label>
<br />
Selected Date: <asp:Label ID="Selected_lb" runat="server"
Text="Selected_Label"></asp:Label>
<br />
Days Till Selected Date: <asp:Label ID="TillSelected_lb" runat="server"
Text="DaysTillSelected_Label"></asp:Label>
<br />
Diwali Date: <asp:Label ID="Diwali_lb" runat="server" Text="Label"></asp:Label>
<br />
Days till Diwali Date: <asp:Label ID="TillDiwali_lb" runat="server"
Text="Label"></asp:Label>
</form>
</body>
</html>
Webform.aspx.cs
using System;
using System.Drawing;
using System.Web.UI.WebControls;
namespace WebApplication_CalendarControl
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Diwali_lb.Text = new DateTime(2023, 11, 10).ToString("dd/MM/yyyy");
TillDiwali_lb.Text = new DateTime(2023, 11,
10).Subtract(DateTime.Today).Days.ToString();
namespace prac3_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();
}
}
}
}
ii. Treeview Operations
WebForm1.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
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 WebApplication3
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
PRACTICAL NO 4.Working with Form Controls
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Name :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Name is required!! please enter
name.." ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
Age :
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Age is required!! please enter age.."
ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ErrorMessage="Enter Valid Age !!" ForeColor="Red" MaximumValue="100"
MinimumValue="15" Type="Integer"
ControlToValidate="TextBox2"></asp:RangeValidator>
<br />
<br />
Email :
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="TextBox3" ErrorMessage="Email is required!! please enter
Email.." ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="TextBox3" ErrorMessage=" Please Enter Valid
Email!! use [@, .]" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\
w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
<br />
<br />
Password :
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox4" ErrorMessage="Password is required!! "
ForeColor="Red" Type="Integer"></asp:RequiredFieldValidator>
<br />
<br />
Confirm password :
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="TextBox5" ErrorMessage="Please Confirm the password!!!"
ForeColor="Red" Type="Integer"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox4" ControlToValidate="TextBox5"
ErrorMessage="Please enter valid password !!check password again.."
ForeColor="Red" Type="Integer"></asp:CompareValidator>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="submit"
/>
<br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
<br />
</div>
</form>
</body>
</html>
Webform1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace prac4
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsValid)
{
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=\"Web\
" /optionInfer+" />
</compilers>
</system.codedom>
</configuration>
Output:
4)B)Create a Web Form to demonstrate use of Adrotator Control.
XmlFile1.xml:
<NavigateUrl>https://attackontitan.fandom.com/wiki/Eren_Yeager</NavigateUrl>
<AlternateText>Eren yeager from attack on titan</AlternateText>
<Impressions>2</Impressions>
<Keyword>AOT</Keyword>
</Ad>
<Ad>
<ImageUrl>tanjiro.jpg</ImageUrl>
<NavigateUrl>https://kimetsu-no-yaiba.fandom.com/wiki/Tanjiro_Kamado</
NavigateUrl>
<AlternateText>Tanjiro from demon slayer</AlternateText>
<Impressions>3</Impressions>
<Keyword>DEMON SLAYER</Keyword>
</Ad>
</Advertisements>
Adrotator.aspx:
<!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" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/XMLFile1.xml"></asp:XmlDataSource>
</div>
</form>
</body>
</html>
Web.config:
Web UserControl1.ascx:
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="WebUserControl1.ascx.cs" Inherits="practical4.WebUserControl1" %>
<h3>6417_Sudesh User control </h3>
<table>
<tr>
<td>
<fieldset>
<asp:Label ID="Label1" runat="server" ></asp:Label>
</fieldset>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Address"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Phone"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Email"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="txtSubmit" runat="server" Text="Submit"
/>
</td>
</table>
Design:
WebForm1.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:WebUserControl1 runat="server" id="WebUserControl1" Header="User Control
Demo_6417" />
</div>
</form>
</body>
</html>
WebUserControl1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical4
{
public partial class WebUserControl1 : System.Web.UI.UserControl
{
private string _header;
public string strURL;
response.Redirect();
}
}
}
PRACTICAL NO 5:Working with Navigation, Beautification and Master
page.
5)A)Create Web Form to demonstrate use of Website Navigation controls and Site Map.
web.sitemap:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"
Inherits="practical5.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
runat="server">
<h1>ABOUT Page</h1>
<p>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
This is About Page</p>
<img src="img/About.png" />
</asp:Content>
Master:
<%@ Master Language="C#" AutoEventWireup="true"
CodeBehind="Site1.Master.cs" Inherits="practical5.Site1" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<header>
<h1>WEB-APP</h1>
<ul>
<li><a href="WebForm1.aspx">Home</a></li>
<li><a href="WebForm2.aspx">About</a></li>
</ul>
</header>
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<asp:Menu ID="Menu1" runat="server"
DataSourceID="SiteMapDataSource1"></asp:Menu>
</form>
<footer>© 6417_Sudesh</footer>
</body>
</html>
Output:
5)B)Create Web Form to demonstrate use of Website Navigation controls and Site Map.
Site1.Master:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.Master.cs"
Inherits="practical5.Site1" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<header>
<h1>WEB-APP</h1>
<ul>
<li><a href="WebForm1.aspx">Home</a></li>
<li><a href="WebForm2.aspx">About</a></li>
</ul>
</header>
</body>
</html>
WebForm1.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="practical5.WebForm1"
%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>Home Page</h1>
<p>This is Home Page</p>
<img src="img/home.jpg" />
</asp:Content>
WebForm2.aspx:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master"
AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="practical5.WebForm2"
%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>ABOUT Page</h1>
<p>This is About Page</p>
<img src="img/About.png" />
</asp:Content>
Output:
5)C)Create a web application to demonstrate various states of ASP.NET Pages.
1)Viewstate
WebForm3.aspx:
WebForm.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical5
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
2)QueryString
WebForm4.aspx:
WebForm4.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs"
Inherits="practical5.WebForm4" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
QUERY STRING 6417_SUDESH:<br />
<br />
USERNAME:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
PASSWORD:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
<br />
<br />
</div>
</form>
</body>
</html>
WebForm.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical5
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
WebForm5.aspx:
<!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" BackColor="#FFFF66" ForeColor="Red"
Text="Query String"></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
</div>
</form>
</body>
</html>
Webform.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace practical5
{
public partial class WebForm5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String Username;
Username=Request.QueryString["username"];
String Password;
Password =Request.QueryString["password"];
Output:
PRACTICAL NO : 6 Working with Database.
6)A) Create a web application that binds data in a multiline textbox by
querying in another textbox.
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:Label ID="name" runat="server" Text="Name"></asp:Label>
<asp:TextBox ID="name_TB" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="show_button" runat="server" Text="show"
/>
<br />
<br />
<asp:TextBox ID="output" runat="server" TextMode="MultiLine" Height="45px"
Width="100px"></asp:TextBox>
</div>
</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;
using System.Data.SqlClient;
using System.Data;
using System.Data.Sql;
namespace prac6
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
SQL Management Studio:
.
OUTPUT:
WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="Practical6.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:DataList ID="DataList1" runat="server">
<ItemTemplate>
ID :
<asp:Label ID="ID_Label" runat="server" Text='<%# Eval("ID") %>' />
<br />
Name :
<asp:Label ID="name_Label" runat="server" Text='<%# Eval("Name") %>' />
<br />
Salary :
<asp:Label ID="salary_Label" runat="server" Text='<%# Eval("Salary") %>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
PRACTICAL NO 7 - Working with Database
7)A) Create a web application to display Data Binding using dropdown list
control.
Source code :
webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="PRAC7.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 />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
webform.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Web.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection.Emit;
namespace PRAC7
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.DataBind();
}
}
7)B) Create a web application to display the phone no of an author using a database.
Source code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="PRAC7.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 />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Web.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection.Emit;
namespace PRAC7
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.DataBind();
}
}
Source code :
webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="PRAC7.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="Insert & Delete Operation on Database"
Font-Bold="True" Font-Size="16pt" ForeColor="#333333"></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text="ID : " Font-Size="14pt"></asp:Label>
<asp:TextBox ID="id_TB" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label3" runat="server" Text="Name : "
Font-Size="14pt"></asp:Label>
<asp:TextBox ID="name_TB" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label4" runat="server" Text="Salary : "
Font-Size="14pt"></asp:Label>
<asp:TextBox ID="salary_TB" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="insert_Btn" runat="server" Text="Insert" >Font-Bold="True" Font-Size="14pt" ForeColor="#33CC33" />
<asp:Button ID="delete_Btn" runat="server" Text="Delete"
Font-Bold="True" Font-Size="14pt" ForeColor="Red" />
<br />
<br />
<asp:Label ID="message" runat="server" Font-Size="13pt"></asp:Label>
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ID" HeaderText="id" SortExpression="id" />
<asp:BoundField DataField="Name" HeaderText="name"
SortExpression="name" />
<asp:BoundField DataField="Salary" HeaderText="salary"
SortExpression="salary" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
webform1.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Web.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services.Description;
namespace PRAC7
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
string str = "INSERT INTO [ ] VALUES(" + id + ", '" + name + "', " + salary + ")";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
}
}
}
Output
Deleting the 6514 record:
8)A) Create a web application to demonstrate data binding using DetailsView and
FormView Control.
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="DetailsView6417.aspx.cs" Inherits="practical7.DetailsView6417" %>
<!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"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" DataKeyNames="ID" DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:NewDB6417ConnectionString %>" SelectCommand="SELECT [ID],
[Name] FROM [Employee]"></asp:SqlDataSource>
</div>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" DataSourceID="SqlDataSource2" Height="50px"
Width="125px">
<EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name" />
<asp:BoundField DataField="Salary" HeaderText="Salary" SortExpression="Salary"
/>
</Fields>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$
ConnectionStrings:NewDB6417ConnectionString %>" SelectCommand="SELECT * FROM
[Employee] WHERE ([ID] = @ID)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" PropertyName="SelectedValue"
Name="ID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:FormView ID="FormView1" runat="server" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3"
CellSpacing="2" DataSourceID="SqlDataSource1" GridLines="Both">
<EditItemTemplate>
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<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" Font-Names="sans-serif"
ForeColor="#8C4510" />
<FooterTemplate>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" DataSourceID="SqlDataSource2" Height="50px"
Width="125px">
<EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name" />
<asp:BoundField DataField="Salary" HeaderText="Salary" SortExpression="Salary"
/>
</Fields>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
</asp:DetailsView>
<br />
THANK YOU....
</FooterTemplate>
<HeaderStyle ForeColor="White" BackColor="#A55129" Font-Bold="True" />
<HeaderTemplate>
Student Information
</HeaderTemplate>
<InsertItemTemplate>
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<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>
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%# Bind("ID") %>' />
<br />
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
<br />
</ItemTemplate>
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<PagerTemplate>1</PagerTemplate>
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
</asp:FormView>
</form>
</body>
</html>
Select a GridView|:
Configure:
Add a DetailsView:
Configure using where:
Add FormView:
Code change in formview:
<EditItemTemplate>
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<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" Font-Names="sans-serif"
ForeColor="#8C4510" />
<FooterTemplate>
<br />
THANK YOU....
</FooterTemplate>
<HeaderStyle ForeColor="White" BackColor="#A55129" Font-Bold="True" />
<HeaderTemplate>
Student Information
</HeaderTemplate>
<InsertItemTemplate>
ID:
<asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("ID") %>' />
<br />
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<ItemTemplate>
ID:
<asp:Label ID="IDLabel" runat="server" Text='<%# Bind("ID") %>' />
<br />
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
<br />
</ItemTemplate>
Output:
BEFORE SELECTION/AFTER SELECTION:
8)B) Create a web application to display Using Disconnected Data Access and
Data binding using GridView.
Source Code:
DisconnectedDB.aspx:
<!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="Show Fetched Data" />
<br />
<br />
<br />
<asp:GridView runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSource1"
> <Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name"
SortExpression="Name" />
<asp:BoundField DataField="Salary" HeaderText="Salary"
SortExpression="Salary" />
</Columns>
</asp:GridView>
<!-- <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:NewDB6417ConnectionString %>" SelectCommand="SELECT * FROM
[Employee]"></asp:SqlDataSource>-->
</div>
</form>
</body>
</html>
Disconnected.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.Data;
using System.Data.Sql;
namespace practical7
{
public partial class DisconnectedDB : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
a) 9)A) Create a web application to demonstrate use of GridView button column and
GridView events.
Source code
Webform.aspx
<!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" AutoGenerateColumns="false"
CellPadding="4" ForeColor="#333333"
GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Name" ItemStyle-Width="150">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Name") %>'>
</asp:TextBox>
</ItemTemplate>
<ItemStyle Width="150px"></ItemStyle>
</asp:TemplateField>
<asp:BoundField DataField="Country" HeaderText="Country" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="Select"
CommandName="Select" CommandArgument="<%# Container.DataItemIndex %>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<div>
</div>
</form>
</body>
</html>
Webform.aspx.cs
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 Gridview
{
public partial class Webform : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!this.IsPostBack)
{
DataTable dt =new DataTable();
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Name"), new
DataColumn("Country") });
dt.Rows.Add("Sudesh", "India");
dt.Rows.Add("Dinesh", "Pakistan");
dt.Rows.Add("Ramesh", "China");
dt.Rows.Add("Rajesh", "Germany");
dt.Rows.Add("Mahesh", "Canada");
dt.Rows.Add("Kamlesh", "USA");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
Design:
Output
b) 9)B) Create a web application to demonstrate GridView paging and Create own
table format using GridView.
WebForm1.aspx.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
WebForm1.aspx.cs
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 Gridview
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
LoadGridData();
}
private void LoadGridData()
{
DataTable dt =new DataTable();
dt.Columns.Add("ID");
dt.Columns.Add("Name");
for (int i=0; i < 10; i++)
{
DataRow dr= dt.NewRow();
dr["ID"] = i +1;
dr["Name"] = "Student" + (i + 1);
dt.Rows.Add(dr);
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs
e)
{
GridView1.PageIndex= e.NewPageIndex;
LoadGridData();
}
}
}
HeaderText & datafield:
Output
c) 9) C)Create a web application to demonstrate use of GridView control template
and GridView hyperlink.
Source code
PRAC9C.PRAC:
<!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"
> <Columns>
<asp:HyperLinkField DataNavigateUrlFields="ID" DataTextField="Name"
HeaderText="Name" DataNavigateUrlFormatString="~\WebForm2.aspx?ID={0}" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="Select"
CommandName="Select" CommandArgument="<%#Container.DataItemIndex %>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
PRAC9.aspx.cs
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 PRAC9C
{
public partial class PRAC9 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("ID"), new
DataColumn("Name"), new DataColumn("Country") });
dt.Rows.Add("6417", "SUDESH", "India");
dt.Rows.Add("6423", "RAMESH", "US");
dt.Rows.Add("6424", "HIMESH", "Spain");
dt.Rows.Add("6432", "RAJESH", "India");
dt.Rows.Add("6403", "BIMLESH", "UK");
dt.Rows.Add("6415", "SANDESH", "Pakistan");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
}
Webform2.aspx:
<!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="Hello and Welcome"></asp:Label><br
/><br /><br />
<img src="https://thumbs.dreamstime.com/b/aspx-file-format-icon-extension-line-
189463972.jpg" />
</div>
</form>
</body>
</html>
Output:
PRACTICAL NO 10 - Working with AJAX and XML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
6417_Prac10a.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.Xml;
namespace WebApplication2
{
public partial class _6417_Prac10a : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
output
myFile.xml:
b) 10)B)Create a web application to demonstrate use of various Ajax controls.
1.Update panel
Source code
UpdatePanel.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>6417_Sudesh Rajbhar</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<br />
<fieldset>
6417_FIRST PANEL:<asp:UpdatePanel runat="server" ID="UpdatePanel"
UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateBtn2" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" ID="Label1" />
<asp:Button runat="server" ID="UpdateBtn1" > Text="Update" />
<br />
<br />
</ContentTemplate>
</asp:UpdatePanel>
</fieldset>
<fieldset>
6417_SECOND PANEL:
<!--Second panel-->
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" ID="Label2" />
<asp:Button runat="server" ID="UpdateBtn2" >Text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
</fieldset>
</div>
</form>
</body>
</html>
Updatepanel.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace _6417_prac10b
{
public partial class _6417_Updatepanel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Timer.aspx
<!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>
<asp:Panel ID="Panel1" runat="server" BackColor="#FFFF99"
BorderStyle="Ridge" BorderColor="#FF3300" BorderWidth="5">
<center>
<asp:Label ID="label2" runat="server" BackColor="#CCFFFF"
Text="Label" Font-Bold="False" Font-Names="Algerian"
ForeColor="#FF3300"></asp:Label>
<asp:Timer ID="timer1" runat="server" Interval="1000"></asp:Timer>
</center>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Timer.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace _6417_prac10b
{
public partial class Timer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
label2.Text = "6417_Page Refreshed at:" + DateTime.Today.ToLongDateString() +
"Time: " + DateTime.Now.ToLongTimeString();
}
}
}
OUTPUT:
<!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:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Label ID="Label2" runat="server" Text="Time is Updated."
ForeColor="#CC33FF"></asp:Label>
</ProgressTemplate>
</asp:UpdateProgress>
<fieldset>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
6417 Update Progress
<br />
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-
Names="Bahnschrift" ForeColor="#FFFF99" ></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Time to Refresh "
BackColor="#FFFF99" BorderColor="Red" BorderStyle="Dotted" Font-
Names="Bahnschrift" />
</ContentTemplate>
</asp:UpdatePanel>
</fieldset>
</div>
</form>
</body>
</html>
UpdatePRogTimer.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace _6417_prac10b
{
public partial class UpdatePRogTimer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(10000);
Button1.Text = DateTime.Now.ToString();
}
}
}
Output:
PRACTICAL NO 11 - Programs to create and use DLL
6417_dll.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="6417_dll.aspx.cs"
Inherits="_6417_Sudesh_dll._6417_dll" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>CALCULATOR</title>
<style>
button {
width: 100%;
box-sizing: border-box; /* Ensure padding and borders don't affect the width */
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<fieldset>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Calculator"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="add_btn" runat="server" Text="ADD"
/>
</td>
<td>
<asp:Button ID="sub_btn" runat="server" Text="SUB"
/>
</td>
</tr>
<tr>
<td>
<asp:Button ID="mul_btn" runat="server" Text="MUL"
/>
</td>
<td>
<asp:Button ID="div_btn" runat="server" Text="DIV"
/>
</td>
</tr>
<tr>
<td>
<asp:Label ID="out_lbl" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
</fieldset>
</div>
</form>
</body>
</html>
6417_dll.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using prac11_dll;
namespace _6417_Sudesh_dll
{
public partial class _6417_dll : System.Web.UI.Page
{
double a, b, output;
Class1 cf = new Class1();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace prac11_dll
{
public class Class1
{
public double add(double a, double b)
{
return a + b;
}
public double sub(double a, double b)
{
return a - b;
}
public double mul(double a, double b)
{
return a * b;
}
public double div(double a, double b)
{
return a / b;
}
}
}
ADD:
SUB:
DIV:
MUL: