AWP Journal of Vishnu 2019-20 Batch

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 87

Hindi Vidya Prachar Samiti’s

RAMNIRANJAN JHUNJHUNWALA COLLEGE


Ghatkopar(W), Mumbai-86

Certificate

This is to certify that Mr. Vishnu Chaurasiya, Roll No. 05 of T.Y.B.Sc (I.T)
class has completed the required number of experiments in the subject of
Advanced Web Programming in the department of Information Technology
during the academic year 2019-2020.

Signature of Internal Guide Sign of Co-ordinator

College Seal & Date Examiner


Practical 1 (a): -
Q. Create an application that obtains four int values from the user and displays the product.

Steps to create Console Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > Console Application from Installed Templates.
3. Enter the Name for the Console Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.

Code: -

Program.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Product
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter First No.");
int a = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter Second No.");


int b = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter Third No.");


int c = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter Fourth No.");


int d = Convert.ToInt32(Console.ReadLine());

int product = a * b * c * d;
int sum = a + b + c + d;

Console.WriteLine("Product " + product+" Sum is "+sum);


Console.ReadLine();

}
}
}
Output: -
Practical 1 (b): -
Q. Create an application to demonstrate string operations.

Steps to create Console Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > Console Application from Installed Templates.
3. Enter the Name for the Console Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.

Code: -
Program.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace String_Pract1b
{
class Program
{
static void Main(string[] args)
{
String s = "Shivam Singh";
Console.WriteLine("Length is "+s.Length);
Console.WriteLine("Lower Case :"+s.ToLower());
Console.WriteLine("Upper Case :"+s.ToUpper());
String s1 = s.Insert(3, "a");
Console.WriteLine("Inserting a at 3 position : "+s1);
Console.WriteLine("Replacing a with v at position 3 : "+s1.Replace("a","v"));
String s2 = s.Remove(3,0);
Console.WriteLine("Remove element at position 3 : " + s2);
String s3 = s.Substring(0,6);
Console.WriteLine("Subtring from 0 to 6 : "+s3);
String con = String.Concat(s3,"annu");
Console.WriteLine("String Concat " + con);
Console.ReadLine();
}
}
}
Output: -
Practical 1 (c): -

Q. 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.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.

Code: -
Default.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button1_Click(object sender, EventArgs e)


{
Label5.Text = "Student Id : " + TextBox1.Text; Label6.Text =
"Student Name :" + TextBox2.Text; Label7.Text = "Student
Course :" + TextBox3.Text; Label8.Text = "Date of Birth :" +
Calendar1.SelectedDate.Date;
}

protected void Button2_Click(object sender, EventArgs e)


{
Label5.Text = "";
Label6.Text = "";
Label7.Text = "";
Label8.Text = "";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
Calendar1.SelectedDates.Clear();
}
}
}

Default.aspx: -
Output: -
Practical 2 (a): -
Q.1 Create simple application to calculate factorial of a number.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.

Code: -
Default.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button1_Click(object sender, EventArgs e)


{
int no = Int32.Parse(TextBox1.Text);
int fact=1;
while (no > 0)
{
fact = fact * no;
no--;

}
Label2.Text = " Factorial Value : " + fact;

}
}
}
Default.aspx: -

Output: -
Practical 2 (a): -
Q.2 Create simple application for Money Conversion.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.

Code: -
Default.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Prac2_MoneyConversion
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button2_Click(object sender, EventArgs e)
{
int cur = Int32.Parse(TextBox1.Text);
Label2.Text = "USD Value :" + (0.014 * cur);
}
protected void Button3_Click(object sender, EventArgs e)
{
int cur = Int32.Parse(TextBox1.Text);
Label3.Text = "Pounds Value :" + (0.012 * cur);
}

protected void Button4_Click(object sender, EventArgs e)


{
int cur = Int32.Parse(TextBox1.Text);
Label4.Text = "Euro Value :" + (0.013 * cur);
}

protected void Button5_Click(object sender, EventArgs e)


{
int cur = Int32.Parse(TextBox1.Text);
Label5.Text = "Yen Value :" + (1.57 * cur);
}
protected void Button6_Click(object sender, EventArgs e)
{
int cur = Int32.Parse(TextBox1.Text);
Label6.Text = "Austrailian Dollar " + (0.021 * cur);
}
}
}

Default.aspx: -
Output: -
Practical 2 (a): -
Q.3 Create simple application for solving Quadratic Equation.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.

Code: -
Default.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button1_Click(object sender, EventArgs e)


{
float a = Int32.Parse(TextBox1.Text);
float b = Int32.Parse(TextBox2.Text);
float c = Int32.Parse(TextBox3.Text);
double x;
double r1, r2;
float det = (b * b) - (4 * a * c);
if(det>0){
x = Math.Sqrt(det);
r1 = (-b + x) / (2 * a);
r2 = (-b - x) / (2 * a);
Label4.Text = "Two Roots are " + r1 +" "+ r2;

}
else if (det == 0)
{
x = Math.Sqrt(det);
r1 = (-b + x) / (2 * a);
Label4.Text = "Only 1 root : " + r1;
}
else {
Label4.Text="There is no root";
}
}
}
}

Default.aspx: -

Output: -
Practical 2 (a): -
Q.4 Create simple application for Temperature Conversion.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.

Code: -
Default.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button2_Click(object sender, EventArgs e)


{
double cel = Convert.ToDouble(TextBox2.Text);
Label4.Text = "Celsius value " + ((cel - 32) * (5 / 9));
}

protected void Button1_Click(object sender, EventArgs e)


{

double fah = Convert.ToDouble(TextBox1.Text);


Label2.Text = "Fahrenheit value " + (fah * (9 / 5) + 32);
}
}
}
Default.aspx: -

Output: -
Practical 2 (b): -
Q.1 Create simple application to demonstrate Function Overloading.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. In the Solution Explorer, Right click and click on “Add” > New Item.
7. Select “Web Form” from Visual C# > Web templates.
8. Type the name of the web form and click on Add.

Code: -
FunctionOverloading.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Prac2_aFn
{
public partial class FunctionOverloading :
System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e)
{
int x = add(2);
int y = add(2, 3);
int z = add(2, 3, 4);
Label1.Text = "Single Parameter add " + x;
Label2.Text = "Double Parameter add " + y;
Label3.Text = "Three Parameter add " + z;
}
public int add(int a)
{
return a + a;
}
public int add(int a, int b)
{
return a + b;
}
public int add(int a, int b, int c)
{
return a + b + c;
}
}
}

FunctionOverloading.aspx: -

Output: -
Practical 2 (b): -
Q.2.a Create simple application to demonstrate Single Inheritance.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. In the Solution Explorer, Right click and click on “Add” > New Item.
7. Select “Web Form” from Visual C# > Web templates.
8. Type the name of the web form and click on Add.

Code: -
SingleInheritance.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button1_Click(object sender, EventArgs e)


{
B s = new B();
int no=Convert.ToInt32(TextBox1.Text);
int square = s.sqr(no);
int cube = s.cube(no);
Label1.Text = "Square is " + square;
Label2.Text = "Cube is " + cube;
}
class A
{
public int sqr(int v1)
{
return v1 * v1;
}
}
class B : A
{
public int cube(int v1)
{
int v = sqr(v1);
return v * v1;
}
}
}
}

SingleInheritance.aspx: -

Output: -
Practical 2 (b): -
Q.2.a Create simple application to demonstrate Single Inheritance.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. In the Solution Explorer, Right click and click on “Add” > New Item.
7. Select “Web Form” from Visual C# > Web templates.
8. Type the name of the web form and click on Add.

Code: -
Multilevel.aspx.cs: -

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

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

protected void Button1_Click(object sender, EventArgs e)


{
double no = Convert.ToDouble(TextBox1.Text);
C s = new C();
double x = s.pow2(no);
double y = s.pow3(no);
double z = s.pow4(no);
Label1.Text = "Power 2 is " + x;
Label2.Text = "Power 3 is " + y;
Label3.Text = "Power 4 is " + z;
}
class A
{
public double pow2(double v1)
{
return v1 * v1;
}
}
class B : A
{
public double pow3(double v1)
{
double val = pow2(v1);
return val * v1;
}
}
class C : B
{
public double pow4(double v1)
{
double val = pow3(v1);
return val * v1;
}
}
}
}

Multilevel.aspx: -
Output: -
Practical 2 (b): -
Q.3 Create simple application to demonstrate Constructor Overloading.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. In the Solution Explorer, Right click and click on “Add” > New Item.
7. Select “Web Form” from Visual C# > Web templates.
8. Type the name of the web form and click on Add.

Code: -
ConstructorOverloading.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Prac2_cConstructor
{
public partial class ConctructorOverloading : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
a s1 = new a(1);
a s2 = new a(2, 3);
a s3 = new a(1, 2, 3);
Label1.Text = s1.r.ToString();
Label2.Text = s2.r.ToString();
Label3.Text = s3.r.ToString();
}
class a
{
public int r;
public a(int v)
{
r=v + v;
}
public a(int a, int b)
{
r = a + b;
}
public a(int a, int b, int c)
{
r = a + b + c;
}

}
}
}

ConstructorOverloading.aspx: -

Output: -
Practical 2 (b): -
Q.4 Create simple application to demonstrate use of Interfaces.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. In the Solution Explorer, Right click and click on “Add” > New Item.
7. Select “Web Form” from Visual C# > Web templates.
8. Type the name of the web form and click on Add.

Code: -
Interface.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Prac2_dInterface
{
public partial class Interface : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
circle c = new circle();
rectangle r = new rectangle();
Label1.Text = "Area of circle is " + c.Cal(4, 0);
Label2.Text = "Area of rectangle is " + r.Cal(5, 4);

}
interface area
{
double Cal(double x, double y);
}
class circle : area
{
public double Cal(double x, double y)
{
return (3.14 * x * x);
}
}
class rectangle : area
{
public double Cal(double x, double y)
{
return (x * y);
}
}
}
}

Interface.aspx: -

Output: -
Practical 2 (c): -
Q.2 Create simple application to demonstrate use of Exception Handling.

Steps to create ASP.Net Web Application: -


1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Web > ASP.NET Web Application from Installed Templates.
3. Enter the Name for the web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. In the Solution Explorer, Right click and click on “Add” > New Item.
7. Select “Web Form” from Visual C# > Web templates.
8. Type the name of the web form and click on Add.

Code: -
Exception.aspx.cs: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Prac_2_dException
{
public partial class Exception : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int r = 2,q=0;
try
{
Label1.Text = "Division is " + (r / q);
}
catch (DivideByZeroException x)
{
Label1.Text = "Exception is " + x.Message;
}
}
}
}
Exception.aspx: -

Output: -
Practical 3(a): -
Q. Create a simple web page with various server controls to demonstrate setting and use
of their properties.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Code: -

Webform1.aspx: -

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

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">


<asp:ListItem>RED</asp:ListItem>
<asp:ListItem></asp:ListItem>
<asp:ListItem>green</asp:ListItem>
</asp:DropDownList>
&nbsp; Choose a background color<br />
<br />
Choose a&nbsp; Font :
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True">
<asp:ListItem>Arial</asp:ListItem>
<asp:ListItem>Calibri</asp:ListItem>
</asp:DropDownList>
<br />
<br />
Specify a numeric font size :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
Select Gender:<br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
<asp:ListItem>male</asp:ListItem>
<asp:ListItem>female</asp:ListItem>
</asp:RadioButtonList>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/WebForm2.aspx">Welcome
Page</asp:HyperLink>
<br />
<br />
Choose your vehicle:<br />
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
RepeatDirection="Horizontal" AutoPostBack="True">
<asp:ListItem>car</asp:ListItem>
<asp:ListItem>bike</asp:ListItem>
<asp:ListItem>cycle</asp:ListItem>
</asp:CheckBoxList>
<br />
<br />
<br />
<br />

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

Webform2.aspx: -

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

&nbsp;&nbsp; Welcome!!!<br />


<br />
<br />
<br />

</div>
</form>
</body>
</html>
Output: -
Practical 3 (b): -
Q. Demonstrate the use of calendar control to perform following operation.
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.

Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -
Code: -
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 Calendar_Control1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void btnResult_Click(object sender, EventArgs e)


{
Calendar1.Caption = "Vacation calender";
Calendar1.FirstDayOfWeek = FirstDayOfWeek.Sunday;
//Calendar1.NextPrevFormat = NextPrevFormat.ShortMonth;
Calendar1.TitleFormat = TitleFormat.Month;
Label2.Text = Calendar1.TodaysDate.ToShortDateString();
Label3.Text = "05-11-2019";
TimeSpan d = new DateTime(2019, 11, 05) - DateTime.Now;
Label4.Text = d.Days.ToString();
TimeSpan d1 = new DateTime(2019, 12, 31) -
DateTime.Now; Label5.Text = d1.Days.ToString();
if (Calendar1.SelectedDate.ToShortDateString() == "05-11-2019")
// date is 5th Nov'19
Label3.Text = "<b>Diwali Festival Starts</b>";
if (Calendar1.SelectedDate.ToShortDateString() == "10-11-2019")
// date is 10th Nov'19
Label3.Text = "<b>Diwali Festival End</b>";
}

protected void btnReset_Click(object sender, EventArgs e)


{
Label1.Text = ""; Label2.Text = "";
Label3.Text = ""; Label4.Text = "";
Label5.Text = "";
Calendar1.SelectedDates.Clear();

}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
Label1.Text = "Your Selected Date:" + Calendar1.SelectedDate.Date.ToString();
}

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)


{
if (e.Day.Date.Day == 5 && e.Day.Date.Month == 11)
{
e.Cell.BackColor = System.Drawing.Color.Yellow;
Label lbl = new Label(); lbl.Text = "<br>DIWALI!";
e.Cell.Controls.Add(lbl);
Image g1 = new Image();
g1.ImageUrl = "diwali.jpg";
g1.Height = 20; g1.Width = 20;
e.Cell.Controls.Add(g1);
}
if (e.Day.Date.Day == 5 && e.Day.Date.Month == 09)
{
Calendar1.SelectedDate = new DateTime(2019, 09, 4);
Calendar1.SelectedDates.SelectRange(Calendar1.SelectedDate,
Calendar1.SelectedDate.AddDays(10));
Label lbl1 = new Label();
lbl1.Text = "<br>Ganpati!";
e.Cell.Controls.Add(lbl1);
}
}
}
}

Output: -
Practical 3 (c): -
Q. Demonstrate the use of Treeview control.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.
8.Add Datalist Control and Add TreeView Control.
9.Add a XML file to the Project.

Design: -
Code: -
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;

namespace Prax3c_treeview
{
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();
}
}
}
}

XMLFile1.xml: -
<?xml version="1.0" encoding="utf-8" ?>
<studentdetail>
<student>
<sid>1001</sid>
<sname>ASHISH CHAVAN</sname>
<sclass>BEIT</sclass>
</student>
<student>
<sid>10022</sid>
<sname>ANIKET GITE</sname>
<sclass>BECS</sclass>
</student>
<student>
<sid>1003</sid>
<sname>SUHAS PIMPLE</sname>
<sclass>TYBCOM</sclass>
</student>
<student>
<sid>1004</sid>
<sname>MAHENDRA SHINDE</sname>
<sclass>TYBA</sclass>
</student>
</studentdetail>

Output: -
Practical 4(a) : -

Q. Create a registration form to demonstrate use of various validation controls.


Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -
Code: -
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 Validation_controls
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (chkAcccept.Checked)
{
if (Page.IsValid)
{
Response.Redirect("WebForm1.aspx");
}
}
else
{
lblMessage.Text = "please accept terms and conditions";
}
}
protected void btnReset_Click(object sender, EventArgs e)
{
txtCPass.Text = "";
txtDOB.Text = "";
txtEmailid.Text = "";
txtFname.Text = "";
txtLname.Text = "";
txtMobile.Text = "";
}
}
}
Output: -
Practical 4(b) : -
Q. Create a web form to demonstrate the use of Adrotator control.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.
8.Go to solution explorer >click on the project name>select add option>new items> data>xml file.
9.Enter the name of the xml file and click on ok.

Code: -

AdvData.xml: -

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

<Advertisements>
<Ad>
<ImageUrl>/Images/Google.png</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText> Please visit Http://www.google.com</AlternateText>
<Impressions>50</Impressions>
<Keyword>Google</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Images/Youtube.png</ImageUrl>
<NavigateUrl>http://www.Youtube.com</NavigateUrl>
<AlternateText>Please visit Http://www.youtube.com</AlternateText>
<Impressions>30</Impressions>
<Keyword>Google</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Images/Amazon.png</ImageUrl>
<NavigateUrl>https://www.amazon.com/</NavigateUrl>
<AlternateText>Please visit Http://www.amazon.com</AlternateText>
<Impressions>20</Impressions>
<Keyword>amazon</Keyword>
</Ad>
</Advertisements>
WebForm1.aspx: -

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

&nbsp;&nbsp;&nbsp;
<asp:AdRotator ID="AdRotator1" Target="_blank" runat="server"
AdvertisementFile="~/AdvData.xml" />
<br />
<br />

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

Output: -
Practical 4(c) : -
Q. Create a web form to demonstrate the use of user controls.
Steps to Follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.
8.Add Web user controls (.ascx) to the Project.

Design: -

Code: -

MenuHost.aspx.cs: -

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

namespace Prax_4c_User_Controls
{
public partial class MenuHost : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["product"] != null)
{
Label1.Text="You CHose"+ Request.Params["product"];
}

}
}
}

LinkMenu.ascx: -

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LinkMenu.ascx.cs"


Inherits="Prax_4c_User_Controls.LinkMenu" %>

<div>
Products:<br />
<asp:HyperLink id="lnkBooks" runat="server"
NavigateUrl="MenuHost.aspx?product=Books"> Books
</asp:HyperLink> <br />
<asp:HyperLink id="lnkToys" runat="server"
NavigateUrl="MenuHost.aspx?product=Toys"> Toys
</asp:HyperLink> <br />
<asp:HyperLink id="lnkSports" runat="server"
NavigateUrl="MenuHost.aspx?product=Sports">
Sports </asp:HyperLink> <br />
<asp:HyperLink id="lnkFurniture" runat="server"
NavigateUrl="MenuHost.aspx?product=Furniture"> Furniture
</asp:HyperLink>
</div>
<p>
&nbsp;</p>
<asp:HyperLink ID="HyperLink1" runat="server">Home</asp:HyperLink>

Output: -
Practical 5( a ): -

Q. Create Web Form to demonstrate use of Website Navigation controls and Site
Map. Steps to Follow: -

1. Open Visual Studio > Click on New Project.


2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. Go to solution explorer >click on the project name>select add option>new items>web forms.
7. Add a Sitemap File by Website - > Add - > Site Map and Name it “Web.Sitemap”.
8. Drag and drop SiteMapDatasource Control and Menu Control from ToolBox to the page.

Design: -

Code: -

Web.sitemap: -

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


<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

<siteMapNode title="Home" description="Home" url="~/default.aspx">


<siteMapNode title="Information" description="Learn about our company">
<siteMapNode title="About Us" description="How RevoTech was founded" url="~/aboutus.aspx" />
<siteMapNode title="Investing" description="Financial reports and investor analysis"
url="~/financial.aspx" />
</siteMapNode>
<siteMapNode title="Products" description="Learn about our products">
<siteMapNode title="RevoStock" description="Investment software for stock charting"
url="~/product1.aspx" />
<siteMapNode title="RevoAnalyze" description="Investment software for yield
analysis" url="~/product2.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap>

Output: -
Practical 5( b ): -
Q. Create a web application to demonstrate use of Master Page with applying Styles and
Themes for page beautification.
Steps to Follow: -

1. Open Visual Studio > Click on New Project.


2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. Go to solution explorer >click on the project name>select add option>new items>web forms.
7. Add a Master Page to the Project and Name it “Site1.Master”.
8.Add two Web forms “aboutus.aspx” and “contact.aspx”.

Design: -
Output: -
Practical 5( c ): -
Q. Create a web application to demonstrate various states of ASP.NET Pages.
( i ) Using ViewState:
Steps to Follow: -

1. Open Visual Studio > Click on New Project.


2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. Go to solution explorer >click on the project name>select add option>new items>web forms.

Design: -

Code: -

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 prax5c_Viewstate
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string str = "TYIT";
if(ViewState ["nam"]== null)
{
ViewState["nam"] = str;
}
}
}

protected void Button1_Click(object sender, EventArgs e)


{
Label1.Text = ViewState["nam"].ToString();

}
}

Output: -
( ii ) Using Query String:
Steps to Follow: -

1. Open Visual Studio > Click on New Project.


2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. Go to solution explorer >click on the project name>select add option>new items>web forms.

Design: -

Webform1.aspx: -

Webform2.aspx: -
Code: -

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 prax5c_Querrystring
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
Response.Redirect("WebForm2.aspx?UserId=" + TextBox1.Text + "&UserName=" + TextBox2.Text);
}
}
}

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 prax5c_Querrystring
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
Label1.Text = Request.QueryString["UserId"];
Label2.Text = Request.QueryString["UserName"];
}

}
}
}
Output: -
( iii ) Using Cookies:
Steps to Follow: -

1. Open Visual Studio > Click on New Project.


2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6. Go to solution explorer >click on the project name>select add option>new items>web forms.

Design: -

WebForm1.aspx: -

Code: -

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 Prax5c_Cookies
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["BackgroundColor"] != null)
{
DropDownList1.SelectedValue = Request.Cookies["BackgroundColor"].Value;
BodyTag.Style["BackgroundColor"] = DropDownList1.SelectedValue;
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{

BodyTag.Style["background-color"] = DropDownList1.SelectedValue;
HttpCookie cookie = new HttpCookie("BackgroundColor");
cookie.Value = DropDownList1.SelectedValue;
cookie.Expires = DateTime.Now.AddMilliseconds(20);
Response.SetCookie(cookie);
}
}
}

Output: -
Practical 6(a): -
Q. Create a web application bind data in a multiline textbox by querying in another
textbox.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

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.Configuration;

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

}
protected void Button1_Click(object sender, EventArgs e)
{
string connstr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connstr);
con.Open();
SqlCommand cmd = new SqlCommand(TextBox1.Text,con);
SqlDataReader reader = cmd.ExecuteReader();
ListBox1.Items.Clear();
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
ListBox1.Items.Add(reader[i].ToString());
}
}
reader.Close();
con.Close();
}
}
}

Output: -
Practical 6(b): -
Q. Create a web application to display records by using database.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

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.Configuration;

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

protected void Button1_Click(object sender, EventArgs e)


{
String connstr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connstr);
SqlCommand cmd = new SqlCommand("select * from practice", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Label1.Text += reader["id"].ToString()+""+reader["NAME"].ToString()+"<br>";

}
reader.Close();
con.Close();
}
}
}

Output: -
Practical 6(c): -
Q. Demonstrate the use of Datalist link control.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Steps to Select Data Source: -

1. Select Choose Data Source Option and select New Data Source.
2. Now Select SQL Database from options and Click Ok button.
3. In next window click on New Connection button.
4. In add connection window Select the available SQL Server Name.
5. Keep the Authentication as Windows Authentication.
6. Then Click on OK button.
7. Once the Connection is made then click on Next button from Data Source Wizard.
8. The next screen gives option to configure the select statement. Here we can choose the table as well
as configure the select statement as we need to display the data on web page.
9. Click on finish.
Output: -
Practical 7(a): -
Q. Create a web application to display Databinding using dropdownlist control.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

WebForm4.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.Configuration;

namespace Prac6_a
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
string connstr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connstr);
SqlCommand cmd = new SqlCommand("Select Name from Practice", con);
con.Open();
SqlDataReader ds = cmd.ExecuteReader();
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "Name";
DropDownList1.DataBind();
ds.Close();
con.Close();
}
}

protected void Button1_Click(object sender, EventArgs e)


{
Label1.Text = "You have selected " + DropDownList1.SelectedValue;
}
}
}

Output: -
Practical 7(b): -
Q. Create a web application for to display the Postal Code no of Customer using database.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

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

namespace P7b_Display_Ph_no
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
string connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("Select Distinct Phone from students",con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
ListBox1.DataSource = reader;
ListBox1.DataValueField = "Phone";
ListBox1.DataBind();
reader.Close();
con.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = " Your Phone NO is " + ListBox1.SelectedValue;
}

}
}

Output: -
Practical 7(c): -
Q. Create a web application for inserting and deleting record from a database. (Using
Execute-Non Query).
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

WebForm5.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.Configuration;

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

protected void Button1_Click(object sender, EventArgs e)


{
string connstr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand cmd1;
string str = "INSERT INTO practice (id,name) VALUES (" + TextBox1.Text + ",'" +
TextBox2.Text + "')";
cmd1=new SqlCommand(str,conn);
cmd1.ExecuteNonQuery();
Label3.Text="add ho gaya";
conn.Close();
}

protected void Button2_Click(object sender, EventArgs e)


{
string connstr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand cmd1;
String str="delete from practice where id="+TextBox1.Text;
cmd1=new SqlCommand(str,conn);
cmd1.ExecuteNonQuery();
Label3.Text="delete kar diya :(";
conn.Close();
}

protected void Button3_Click(object sender, EventArgs e)


{
string connstr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection conn = new SqlConnection(connstr);
GridView1.Visible = true;
conn.Open();
String str = "select * from practice ";
SqlCommand cmd; cmd = new SqlCommand(str, conn);

SqlDataReader dr1; dr1 = cmd.ExecuteReader();

GridView1.DataSource = dr1;
GridView1.DataBind();
Label3.Text = "Processing";
conn.Close();
}
}
}
Output: -
Practical 8(a): -
Q. Create a web application to demonstrate various uses and properties of
SqlDataSource.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

WebForm6.aspx.cs: -

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

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

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{
SqlDataSource2.SelectCommand = "select * from practice where id='"
+ DropDownList1.SelectedValue+"'";
}
}
}

Output: -
Practical 8(b): -
Q. Create a web application to demonstrate data binding using DetailsView and
FormView Control.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Steps to Enable Paging: -

1. Add a Sql Data Source for both FormView and DetailsView.


2. Enable Paging for Both the Controls.
Output: -
Practical 8(c): -
Q. Create a web application to display Using Disconnected Data Access and Data
Binding using GridView.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

WebForm8.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.Configuration;
using System.Data.SqlClient;

namespace Prac6_a
{
public partial class WebForm8 : 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=SHIVAM\\SQLEXPRESS;Integrated
Security=True");
GridView1.Visible=true;
conn.Open();
string str = "select name from practice";
SqlCommand cmd= new SqlCommand(str, conn);
SqlDataAdapter objDa = new SqlDataAdapter();
DataSet ds=new DataSet();
cmd.CommandType = CommandType.Text;
objDa.SelectCommand = cmd;
objDa.Fill(ds, "practice");
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
conn.Close();
}
}
}

Output: -
Practical 10(a): -
Q. Create a web application to demonstrate reading and writing operation with XML.
Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -
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 WebApplication2
{
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 writer = new XmlTextWriter("C:\\Users\\SHIVAM SINGH\\Documents\\Visual Studio
2010\\Projects\\WebApplication2\\WebApplication2\\XMLFile1.xml",null);
writer.WriteStartDocument();
writer.WriteStartElement("Details","");
writer.WriteElementString("id","1");
writer.WriteElementString("name","annu");
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
Label1.Text="data write";
}

protected void Button2_Click(object sender, EventArgs e)


{
String xmlNode = "C:\\Users\\SHIVAM SINGH\\Documents\\Visual Studio
2010\\Projects\\WebApplication2\\WebApplication2\\XMLFile1.xml";
XmlReader reader=XmlReader.Create(xmlNode);
while(reader.Read())
{
switch(reader.NodeType){
case XmlNodeType.Element:
ListBox1.Items.Add("<"+reader.Name+">");
break;
case XmlNodeType.Text:
ListBox1.Items.Add("<"+reader.Value+">");
break;
case XmlNodeType.EndElement:
ListBox1.Items.Add("<"+reader.Name+">");
break;

}
}
Output: -
Practical 10(a): -
Q. Create a web application to demonstrate use of various Ajax controls.
(i) Partial PostBack and Total PostBack Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

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)
{
}

protected void Button1_Click(object sender, EventArgs e)


{
string time = DateTime.Now.ToLongTimeString();
Label1.Text = "showing time from outside" + time;
}

protected void Button2_Click(object sender, EventArgs e)


{
string time = DateTime.Now.ToLongTimeString();
Label2.Text = "showing time from panel" + time;

}
}
}

Output: -
(ii) Using Timer Control Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

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 WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

protected void Button1_Click(object sender, EventArgs e)


{
System.Threading.Thread.Sleep(1);
}

protected void Timer1_Tick(object sender, EventArgs e)


{
Label1.Text = DateTime.Now.ToString();
}
}
}
Output: -
(ii) Using Update Progress Steps to follow: -
1. Open Visual Studio > Click on New Project.
2. Select Visual C# > Windows > empty Web Application from Installed Templates.
3. Enter the Name for the Web Application and the Location to the save the project.
4. Click on Ok.
5. Your Project is created.
6.Go to solution explorer >click on the project name>select add option>new items>web forms.
7.Enter the name of the web form and click on ok.

Design: -

Code: -

WebForm3.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 WebForm3 : 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 = "Processing completed";
}
}
}
Output: -

You might also like