Awp Practical
Awp Practical
PRACTICAL NO. 1
1a).AIM: Create an application to print on screen the output of adding,
subtracting, multiplying and dividing two numbers entered by the user
in C#.
Code Source:
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a, b, c, d, e,f;
Console.WriteLine(“Enter the 2 numbers”;);
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
c=a-b;
d=a+b;
e=a*b;
f=a/b;
Console.WriteLine(“Subtraction Result”+c);
Console.WriteLine(“Addition Result”+d);
Console.WriteLine(“Product Result”+e);
Console.WriteLine(“Division Result”+f);
Console.ReadKey();
}
}}
Output:
Code Source:
using System;
class GFG
{
static void printFloydTriangle(int n)
{
int i, j, val = 1;
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write(val + " ");
val++;
}
Console.WriteLine();
}
}
// Driver Code
public static void Main()
{
printFloydTriangle(6);
}
}
Output:
Code Source:
using System;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int num1=0,num2=1,num3,num4,num,counter;
Console.Write ("Upto how many number you want fibonacci
series:");
num=int.Parse(Console.ReadLine());
counter=3;
Console.Write(num1+"\t"+num2);
while(counter<=num)
{
num3 = num1 + num2;
if (counter >= num)
break;
Console.Write("\t" + num3);
num1 = num2;
num2 = num3;
counter++;
}
}}}
Output:
Output:
PRACTICAL NO. 2
2a.)AIM: Create a simple application to demonstrate the concepts boxing
and unboxing.
Code Source:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AWPPRACTICAL2A
{
class Program
{
static void Main(string[] args)
{
int x = 10;
object y = x; //Boxing
Console.WriteLine("Boxing output" + y);
int z = (int)y; //Unboxing
Console.WriteLine("Unboxing" + z);
Console.ReadLine();
}
}
}
Output:
Code Source:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1d
{
delegate int Arith(int x, int y);
class Prg
{
public static int Add(int a, int b)
{
return (a + b);
}
public static int Sub(int a, int b)
{
return (a - b);
}
}
class Program
{
static void Main(string[] args)
{
Arith op1 = new Arith(Prg.Add);
Arith op2 = new Arith(Prg.Sub);
int r1 = op1(10, 20);
int r2 = op2(20, 5);
Console.WriteLine("Addition=" + r1);
Console.WriteLine("subtraction=" + r2);
Console.ReadKey();
}
}
}
Output:
Code Source:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
namespace interface1
{
interface Addition
{
int Add();
}
interface Multiplication
{
int Mul();
}
class A : Addition, Multiplication
{
public int x, y;
public A(int a, int b)
{
x = a;
y = b;
Console.WriteLine("1ST NO:" + x);
Console.WriteLine("2ND NO:" + y);
}
public int Add()
{
return (x + y);
}
public int Mul()
{
return (x * y);
}
}
class MultipleInterface
{
static void Main(string[] args)
{
A a1 = new A(10, 20);
Addition obj = (Addition)a1;
Multiplication obj1 = (Multiplication)a1;
Console.WriteLine("Addition=" + obj.Add());
Console.WriteLine("Multiplication=" + obj1.Mul());
Console.ReadKey();
}
}
}
Output:
PRACTICAL NO. 3
3a).AIM: Create a simple application to demonstrate your vacation
using calendar control .
Calendar.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Prac4a_final
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Calendar1_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)
{
if (e.Day.Date.Day == 5 && e.Day.Date.Month == 9)
{
e.Cell.BackColor = System.Drawing.Color.Yellow;
Label lbl = new Label();
lbl.Text = "<br>Teachers Day!";
e.Cell.Controls.Add(lbl);
Image g1 = new Image();
g1.ImageUrl = "td.jpg";
g1.Height = 20;
g1.Width = 20;
e.Cell.Controls.Add(g1);
}
}
}
Output:
Treeview,aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Treeview control navigation:<br />
<br />
</div>
<asp:TreeView ID="TreeView1" runat="server">
<Nodes>
<asp:TreeNode Text="Root" Value="Root">
<asp:TreeNode Text="Web Pages" Value="Web Pages">
<asp:TreeNode NavigateUrl="~/WebForm1.aspx" Text="Page 1"
Value="Page 1"></asp:TreeNode>
<asp:TreeNode NavigateUrl="~/WebForm3.aspx" Text="Page 2"
Value="Page 2"></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</form>
</body>
</html>
PRACTICAL NO. 4
4a.Adrotator.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs"
Inherits="Prac4a_final.WebForm3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1"
OnAdCreated="AdRotator1_AdCreated" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/ADfile.xml"></asp:XmlDataSource>
</form>
</body>
</html>
‘
Output:
Output:
PRACTICAL NO. 5
5a) Create a simple web form with various server controls to demonstrate
settings and use of the properties.
5b) Create a registration form to demonstrate the use of validation controls
Type Login Form, Username and Password , Confirm Password in the respective columns
Add 3 text boxes in the columns and ‘Reset’ and ‘Submit’ button in columns
Click Edit ItemsAdd ( in the dialog box)Enter ‘Bsc It’ in Text and Value Click OK
Navigation Control
Validation
PRACTICAL NO. 6
6a)aim:create a web application for inserting and deleting records from
database.
Click Next
Give Name to the Project
(A blank Project will be created)
Add a new Web Form in the Project)
Add a GridView
Click on the side arrow and choose New data source option.
If you want to save the connection string with different name you can save
PRACTICAL NO. 7
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Pract_6a
{
public partial class Default1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{string connStr = "Data Source = HP-LAPTOP; Initial Catalog = practical; Integrated
Security = True";
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("Select Distinct city from customer1", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DropDownList1.DataSource = reader;
DropDownList1.DataTextField = "city";
DropDownList1.DataBind();
reader.Close();
con.Close(); } }
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "The You Have Selected : " + DropDownList1.SelectedValue;
}}}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Pract_6a
{
public partial class Default3 : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{ } protected void Button1_Click(object sender, EventArgs e)
{ string connStr = "Data Source = HP-LAPTOP; Initial Catalog = practical; Integrated
Security = True";
SqlConnection con = new SqlConnection(connStr);
string InsertQuery = "insert into customer1
values(@custid,@custname,@city,@orderid,@mobileno)";
SqlCommand cmd = new SqlCommand(InsertQuery, con);
cmd.Parameters.AddWithValue("@custid", TextBox1.Text);
cmd.Parameters.AddWithValue("@custname", TextBox2.Text);
cmd.Parameters.AddWithValue("@city", TextBox3.Text);
cmd.Parameters.AddWithValue("@orderid", TextBox4.Text);
cmd.Parameters.AddWithValue("@mobileno", TextBox4.Text);
con.Open();
cmd.ExecuteNonQuery();
Label1.Text = "Record Inserted Successfuly.";
con.Close();
}protected void Button2_Click(object sender, EventArgs e)
{
string connStr = "Data Source = HP-LAPTOP; Initial Catalog = practical; Integrated
Security = True";
SqlConnection con = new SqlConnection(connStr);
string InsertQuery = "delete from customer1 where custid=@custid";
SqlCommand cmd = new SqlCommand(InsertQuery, con);
cmd.Parameters.AddWithValue("@custid", TextBox1.Text);
con.Open();
cmd.ExecuteNonQuery();
Select SqlDataSource After Selecting the previous DataSource the details in the Form View will be
changed
Click the enable paging option checkbox(You can select different Format y choosing Auto Format
option)
Output:
Details View From the tool box select details view and Drag and drop in the view form.
Select the existing data source created.(If not created the datasource then create as per the
previous steps of Configuring the Sql data Source)
Select the Data Field you want to bound to , give proper Header name to the column and
click on OK
The same will be reflected in the details view
Output
PRACTICAL NO. 8
8a)Create a web application to denote Bootsrap installation and JS
Bootsrap button
Bootstrap installation in Visual studio
<html lang="en">
<head runat="server">
<meta charset="UTF-8">
</div>
</form>
</body></html>
OUTPUT:
After dragging the Script Manager In the toolbox→ Drag the timer
Click on install
Default.aspx
Default.aspx.cs
using Newtonsoft.Json;
using System.Reflection.Emit;
using System.Security.Principal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Nuget
Email = "[email protected]",
};
string json =
JsonConvert.SerializeObject(account, Newtonsoft.Json.Formatting.Indented);
Label1.Text = json;
Output