Awp Practicals
Awp Practicals
Awp Practicals
NET)
1(a). create an application that obtain four int values from the users and displays the
product.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Practical_1a
num1 = Convert.ToInt32(TextBox1.Text);
num2 = Convert.ToInt32(TextBox2.Text);
num3 = Convert.ToInt32(TextBox3.Text);
num4 = Convert.ToInt32(TextBox4.Text);
TextBox5.Text = Convert.ToString(prod);
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
for(int i=0;i<words.Length;i++)
TextBox2.Text =TextBox2.Text+words[i]+"\n\r";
1(c). Create an application that receive the (Student Id, Student Name, Course Name,
Date of Birth) information from a set of students. The application should also dislplay
the information of all the students once the data entered.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
struct Student
int i;
s[i].studid = TextBox2.Text;
s[i].name = TextBox3.Text;
s[i].cname = TextBox4.Text;
s[i].dob = TextBox5.Text;
Response.Write("<br>");
Response.Write("<br>");
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
num4= int.Parse(TextBox1.Text);
num = 3;
Response.Write("Fiboncci sereis.");
if (num>= num4)
break;
Response.Write("\t" + num3);
num1 = num2;
num2 = num3;
num++;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
int n, i, c;
n = int.Parse(TextBox1.Text);
if ((n % c) == 0)
break;
if (n == 1)
else if (c < n - 1)
else
} }
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
String ch;
int count = 0;
ch = TextBox1.Text;
count++;
Response.Write("<br>");
Response.Write("<br>");
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
int[] a = { 1, 2, 3, 4 };
foreach (int x in a)
Response.Write(x);
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
num = int.Parse(TextBox1.Text);
actualnumber = num;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
num =Convert.ToInt32(TextBox1.Text);
f= f * i;
Response.Write("<br>");
}}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public double r, e, d;
public Class1()
r = 0; e = 0; d = 0;
double ev = 60;
r = d * ev;
double ev = 80;
r = e * ev;
double ev = 65;
d = r / ev;
double ev = 80;
e = r / ev;
Class1 f1;
f1 = new Class1();
if (RadioButton2.Checked == true)
f1.r = Convert.ToInt16(TextBox1.Text);
f1.convertrtod();
f1.d = Convert.ToInt16(TextBox1.Text);
f1.convertdtor();
if (RadioButton3.Checked == true)
f1.e = Convert.ToInt16(TextBox1.Text);
f1.convertetor();
if (RadioButton4.Checked == true)
f1.r = Convert.ToInt16(TextBox1.Text);
f1.convertrtoe();
}
else
{
r1 = (-b) / (2 * a);
}
}
}
namespace practical
{
public partial class Qudratic_equation : System.Web.UI.Page
{
Quadraticroots q;
}
else if (d > 0)
{
Response.Write("\nRoots are Real and Distinct<br>");
Response.Write("\nFirst Root is" + q.r1 + "<br>");
Response.Write("\nSecond Root is" + q.r2 + "<br>");
}
else
{
Response.Write("\nRoots are Imaginary <br>");
Response.Write("\nFirst Roots is"+q.r1+"<br>");
Response.Write("\nSecond Roots is"+q.r2+"<br>");
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class converttemp
public converttemp()
celsius = 0;
faren = 0;
converttemp c;
c = new converttemp();
char ch;
ch = Convert.ToChar(TextBox1.Text);
if (ch == 'c')
c.celsius = float.Parse(TextBox2.Text);
c.converttofaren();
else
c.faren = float.Parse(TextBox2.Text);
c.converttocel();
Label1.Text="Farenheit to Celsius\n"+c.celsius;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class overloading
int x;
return x = a + b;
return y = a + b + c;
float u;
return u = a + b;
float v;
return v = a + b + c;
overloading o;
o = new overloading();
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public int d;
return p;
return s;
Response.Write("<br>" + d.derivedmethod());
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class A
class B : A
class C : B
Response.Write(obj.show() + "<br>");
Response.Write(obj.display() + "<br>");
Response.Write(obj.show1() + "<br>");
Multiple Inheritance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
side = s;
int area;
sq.setSide(15);
area = sq.getArea();
int c = sq.getCost(area);
Hierarchical Inheritance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class A
return "Welcome";
class B : A
class C : A
C c1 = new C();
B b1 = new B();
string s = "";
s += b1.display();
s += c1.show1();
Label1.Text=s;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
class MarkSheet
string name;
public MarkSheet()
m1 = 20;
m3 = 40;
m1 = ms;
m1 = ms1;
m2 = ms2;
m1 = ms1;
m2 = ms2;
m3 = ms3;
float t = m1 + m2 + m3;
return t;
Response.Write(a.tot() + "<br>");
Response.Write(b.tot() + "<br>");
Response.Write(c.tot() + "<br>");
Response.Write(d.tot() + "<br>");
(iv) Interface
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
string retcode();
double amtfunc();
public Transaction()
tCode = "";
amount = 0.0;
tCode = c;
amount = a;
return amount;
return tCode;
Response.Write("<br>Code" + t1.retcode());
Response.Write("<br>Amount" + t1.amtfunc());
Response.Write("<br>Code" + t2.retcode());
Response.Write("<br>Amount:" + t2.amtfunc());
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
sd();
sd += new SimpleDelegate(secfunction);
sd();
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
: base(msg)
int num;
try
num = int.Parse(TextBox1.Text);
if (num < 0)
else
Console.WriteLine("Positive Number");
catch(NegativeException en)
Response.Write(en.Message);
Calndrctrl.aspx
ShowGridLines="True" Width="300px"
OnSelectionChanged="Calendar1_SelectionChanged" >
ForeColor="#CC9966" />
</asp:Calendar>
calndrCtrl.aspx.cs
protected void btnResult_Click(object sender, EventArgs e)
{
if (Calendar1.SelectedDate.ToShortDateString() == "9-13-2018")
Label3.Text = "<b>Ganpati Festival Start</b>";
if (Calendar1.SelectedDate.ToShortDateString() == "9-23-2018")
{
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);
e.Cell.Controls.Add(g1);
}
if (e.Day.Date.Day == 13 && e.Day.Date.Month == 9)
{
Calendar1.SelectedDate.AddDays(10));
Label lbl1 = new Label();
Label3.Text = "";
Label4.Text = "";
Label5.Text = "";
Calendar1.SelectedDates.Clear();
}
OUTPUT
<sname>Tushar</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>2</sid>
<sname>Sonali</sname>
<sclass>TYCS</sclass>
</student>
<student>
<sid>3</sid>
<sname>Yashashree</sname>
<sclass>TYIT</sclass>
</student>
<student>
<sid>4</sid>
<sname>Vedshree</sname>
<sclass>TYCS</sclass>
</student>
</studentdetail>
Default2.aspx
Value="BLUE"></asp:TreeNode>
{
if (!IsPostBack)
{
BindData();
}
}
else
{
DataList1.DataBind();
}
}
}
<Advertisements>
<Ad>
<ImageUrl>rose1.jpg</ImageUrl>
<NavigateUrl>http://www.1800flowers.com</NavigateUrl>
<AlternateText>
Order flowers, roses, gifts and more
</AlternateText>
<Impressions>20</Impressions>
<Keyword>flowers</Keyword>
</Ad>
<Ad>
<ImageUrl>rose2.jpg</ImageUrl>
<NavigateUrl>http://www.babybouquets.com.au</Navigat
eUrl> <AlternateText>Order roses and
flowers</AlternateText> <Impressions>20</Impressions>
<Keyword>gifts</Keyword>
</Ad>
<Ad>
<ImageUrl>rose3.jpeg</ImageUrl>
<NavigateUrl>http://www.flowers2moscow.com</Navigat
eUrl> <AlternateText>Send flowers to
Russia</AlternateText>
<Impressions>20</Impressions>
<Keyword>russia</Keyword>
</Ad>
</Advertisements>
Default.aspx
<asp:AdRotator ID="AdRotator1" runat="server"
DataSourceID="XmlDataSource1" />
OUTPUT:
Website -> Add -> Web User Control and Name it ‘MyUserControl.
MyUserControl.ascx
<asp:TextBox ID="txtName"
runat="server"></asp:TextBox> </td>
</tr>
<tr>
<td></td>
<td>
</td>
</tr>
<tr>
<td></td>
<td>
</tr>
</table><br />
<asp:Label ID="Label1" runat="server" ForeColor="White" Text="
"></asp:Label>
UserControlDisplay.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="UserControlDisplay.aspx.cs"
Inherits="UserControlDisplay" %>
<%@ Register Src="~/MyUserControl.asc TagPrefix="uc"
TagName="Student"%>
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Master Page Demo</title>
<link href="css/my.css" rel="stylesheet" />
</asp:ContentPlaceHolder>
<style type="text/css">
.auto-style1 {
position: absolute;
top: 373px;
left: 1028px;
bottom: 303px;
}
.auto-style2 {
position: absolute;
top: 537px;
left: 1016px;
z-index: 1;
</style>
</head>
<!DOCTYPE html>
<form id="form1" runat="server">
<html>
<head>
<title>Master</title>
<body>
<header id="header">
<nav id="nav">
<ul>
<li><a href="home.aspx">Insight</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Downloads</a></li>
<li><a href="#">Contact Us</a></li>
</nav>
<aside
id="side">
<h1>Info</
h1>
</asp:ScriptManager>
</a>
</p>
</aside>
<div id="con">
</asp:ContentPlaceHolder>
</div>
<footer id="footer">
copyright @Sambare
</footer>
</body>
</html>
</form>
</body>
</html>
</asp:Content>
<asp:Content ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1"
runat="server"> <h1>Home page</h1>
</asp:Content>
StyleSheet.css
#header{
color: blueviolet;
text-align: center;
font-size: 20px;
padding: 5px;
ul{
list-style-type: none;
}
li a {
color:crimson ;
font-size: 30px;
column-width: 5%;
li
{
display: inline;
padding-left: 2px;
a{
text-decoration: none;
margin-left:20px
li a:hover{
background-color: aqua;
color:coral ;
padding:1%;
}
#side{
text-align: center;
float: right;
width: 15%;
padding-bottom: 79%;
background-color: #F1FAEE;
}
background-color: burlywood;
padding: 10px;
padding-bottom: 75%;
#footer{
background-color: #C7EFCF;
text-align:center;
padding-bottom: 5%;
font-size: 20px;
#con{
border:double;
border-color:burlywood;
1. Create a webpage with one Button, one Multiline TextBox and one list
box with setting TextMode Property of text box to Multiline as shown
below
2. Write the Database related code in code behind C# file as given below .
Web.confing
<configuration>
<system.web>
<compilation debug="true"
targetFramework="4.5.2" />
<httpRuntime
targetFramework="4.5.2" />
</system.web>
<connectionStrings>
<add name="connStr" connectionString="Data
Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='C:\
Users\tushars\Documents\Visual Studio
2015\WebSites\Workshop\App_Data\
Database.mdf';Integrated Security=True" />
</connectionStrings>
</configuration>
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.Data.SqlClient;
using System.Configuration;
{
protected void Button1_Click(object sender, EventArgs e)
{
string connStr =
ConfigurationManager.ConnectionStrings["connStr"].Connection
String;
Output:
string connStr =
ConfigurationManager.ConnectionStrings["connStr"].Connection
String;
while (reader.Read())
Output:
1. Drag the Datalist control to our web page form toolbox->Data-> Datalist.
2. Then select Choose Data Source Option and select <New Data Source>.
12.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.
13. In next screen we can test our query to check the output. Then
Click on finish.
After successful steps form the Datalist controls option wizard our web page
design and output will look like following.
1. Create a web page with DropDownList control, one Button and one Label
control.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
{
if (IsPostBack == false)
string connStr =
ConfigurationManager.ConnectionStrings["connStr"].Connection
String;
DropDownList1.DataSource = reader;
DropDownList1.DataTextField = "City";
DropDownList1.DataBind();
con.Close();
}
Output:
(b): Create a web application for to display the Postal Code no of Customer
using database.
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.Data.SqlClient;
using System.Configuration;
Label1.Text = ListBox1.SelectedValue;
string connStr =
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
con.Open();
ListBox1.DataTextField = "City";
ListBox1.DataValueField = "POSTAL_CODE";
ListBox1.DataBind();
reader.Close();
con.Close();
(c): Create a web application for inserting and deleting record from a
database. (Using Execute-Non Query).
Create a web page with TextBox, and Two Button and one Label control as shown
below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
string connStr =
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
cmd.Parameters.AddWithValue("@ADDRESS", TextBox1.Text);
cmd.Parameters.AddWithValue("@CITY", TextBox2.Text);
cmd.Parameters.AddWithValue("@NAME", TextBox3.Text);
cmd.Parameters.AddWithValue("@STATE", TextBox4.Text);
cmd.Parameters.AddWithValue("@ZIP_CODE", TextBox5.Text);
con.Open();
cmd.ExecuteNonQuery();
}
protected void Button2_Click(object sender, EventArgs e)
string connStr =
ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection con = new SqlConnection(connStr);
cmd.Parameters.AddWithValue("@NAME", TextBox1.Text);
con.Open( );
cmd.ExecuteNonQuery( );
con.Close( );
Coding:-
Default aspx
<
%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Defaul
t"%>
Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:GridViewID="GridView1"runat="server">
</asp:GridView>
<br/>
<asp:ButtonID="Button1"runat="server"onclick="Button1_Click"Text="Button"/>
</div>
</form>
</body>
</html>
publicpartialclass_Default : System.Web.UI.Page
SqlConnection cn;
SqlCommand co;
SqlDataAdapter ds;
DataSet da;
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
ds.Fill(da, "stdetail");
GridView1.DataSource = da.Tables[0];
GridView1.DataBind();
OUTPUT:
XMLREADER.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;
public partial class _Default : 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/pc-17/Documents/Visual Studio
2010/WebSites/WebSite23/sid/demo.xml", null);
writer.WriteStartDocument();
writer.WriteStartElement("Details", "");
writer.WriteElementString("ID", "09");
writer.WriteElementString("FirstName", "Sunita");
writer.WriteElementString("LastName", "Nithur");
writer.WriteElementString("Salary", "50000");
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
2010/WebSites/WebSite23/sid/demo.xml");
while (xReader.Read())
{
switch (xReader.NodeType)
{
XMLREADWRITE.ASPX
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<body>
<div>
onclick="Button1_Click" />
<br />
</div>
<asp:ListBox ID="ListBox1" runat="server" Height="222px"
Width="492px"></asp:ListBox>
<br />
<br />
onclick="Button2_Click" />
<br />
<br />
</form>
</body>
</html>
Demo.xml
<?xml
version="1.0"?><Details><ID>36</ID><FirstName>Siddharth</FirstName><LastName>Mudul
</LastName><Salary>50000</Salary></Details>
1. Go to File Menu
2. Select New Project using C#.
3. Select option Class Library and Click Ok.
Class1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary5
publicclassClass1
{
int result;
if (num == 1)
{
return 1;
}
else
{
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary5;
namespace ConsoleApplication1
classProgram
ClassLibrary5.Class1 c=newClassLibrary5.Class1();
int t = c.factorial(5);
Console.ReadKey();
OUTPUT: