AWP Journal of Vishnu 2019-20 Batch
AWP Journal of Vishnu 2019-20 Batch
AWP Journal of Vishnu 2019-20 Batch
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.
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());
int product = a * b * c * d;
int sum = a + b + c + d;
}
}
}
Output: -
Practical 1 (b): -
Q. Create an application to demonstrate string operations.
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.
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)
{
Default.aspx: -
Output: -
Practical 2 (a): -
Q.1 Create simple application to calculate factorial of a number.
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)
{
}
Label2.Text = " Factorial Value : " + fact;
}
}
}
Default.aspx: -
Output: -
Practical 2 (a): -
Q.2 Create simple application for Money Conversion.
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);
}
Default.aspx: -
Output: -
Practical 2 (a): -
Q.3 Create simple application for solving Quadratic Equation.
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)
{
}
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.
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)
{
Output: -
Practical 2 (b): -
Q.1 Create simple application to demonstrate Function Overloading.
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.
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)
{
SingleInheritance.aspx: -
Output: -
Practical 2 (b): -
Q.2.a Create simple application to demonstrate Single Inheritance.
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)
{
Multilevel.aspx: -
Output: -
Practical 2 (b): -
Q.3 Create simple application to demonstrate Constructor Overloading.
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.
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.
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>
</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>
</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 Calendar1_SelectionChanged(object sender, EventArgs e)
{
Label1.Text = "Your Selected Date:" + Calendar1.SelectedDate.Date.ToString();
}
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) : -
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: -
<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>
<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: -
<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>
</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: -
Design: -
Code: -
Web.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: -
Design: -
Output: -
Practical 5( c ): -
Q. Create a web application to demonstrate various states of ASP.NET Pages.
( i ) Using ViewState:
Steps to Follow: -
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;
}
}
}
}
}
Output: -
( ii ) Using Query String:
Steps to Follow: -
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)
{
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: -
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;
}
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)
{
}
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: -
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();
}
}
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)
{
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)
{
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: -
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)
{
}
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)
{
}
}
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)
{
}
}
}
}
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)
{
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)
{