0% found this document useful (0 votes)
7 views

AWDpractical Manual

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

AWDpractical Manual

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 54

Practical no.

1A
step1: create a new project and add a web form .
Solution Explorer>right click on project name>Add>new WebForm
file>ok

Step2: click on design


Design :

Step3: Double click on every button and write a code


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public class Calculation
{
public int a, b, ans;
public void add()
{
ans = a + b;
}
public void sub()
{
ans = a - b;
}
public void multi()
{
ans = a * b;
}
public void div()
{
ans = a / b;
}
}
namespace pract1AAA
{
public partial class WebForm1 : System.Web.UI.Page
{
Calculation c;
protected void Page_Load(object sender, EventArgs e)
{
c = new Calculation();
}
protected void Button1_Click(object sender, EventArgs e)
{
c.a = Convert.ToInt32(TextBox1.Text);
c.b = Convert.ToInt32(TextBox2.Text);
c.add();
Label3.Text = c.ans.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
c.a = Convert.ToInt32(TextBox1.Text);
c.b = Convert.ToInt32(TextBox2.Text);
c.sub();
Label3.Text = c.ans.ToString();
}
protected void Button3_Click(object sender, EventArgs e)
{
c.a = Convert.ToInt32(TextBox1.Text);
c.b = Convert.ToInt32(TextBox2.Text);
c.multi();
Label3.Text = c.ans.ToString();
}
protected void Button4_Click(object sender, EventArgs e)
{
c.a = Convert.ToInt32(TextBox1.Text);
c.b = Convert.ToInt32(TextBox2.Text);
c.div();
Label3.Text = c.ans.ToString();
}
}
}

Step4: Run the Project.


OUTPUT:
Practical No. 1B
Step1:Create Web Form
Solution Explorer>right click on project name>Add>new WebForm
file>ok
Step2: click on design
Design:
Step3: Double click on button and write a code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public class shape
{
public int x, y, z;
public void getSide(int length, int breadth, int width)
{
x = length;
y = breadth;
z = width;
}
}
namespace P1b
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int noOfRows, row, col, n = 1;
noOfRows = Convert.ToInt32(TextBox1.Text);
for (row = 1; row <= noOfRows; row++)
{
for (col = 1; col <= row; col++)
{
Response.Write(n++ + " ");
}
Response.Write("<br/>");
}
}
}
}

Step4: Run the Project.


OUTPUT:

Practical No.1C
1.Generate Fibonacci series

Step1:Create Web Form


Solution Explorer>right click on project name>Add>new WebForm
file>ok
Step2: click on design
Design:
Step3: Double click on button and write a code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls
namespace pract1c
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int num, n1 = 0, n2 = 1, n3, i;
num = Convert.ToInt32(TextBox1.Text);
Response.Write(n1 + "\t" + n2);
i = 0;
while (i <= num)
{
n3 = n1 + n2;
Response.Write("\t" + n3);
n1 = n2;
n2 = n3;
i++;
}
}
}
}
Step4: Run the Project.
OUTPUT:

2.Test for Prime numbers

Step1:Create Web Form


Solution Explorer>right click on project name>Add>new WebForm
file>ok
Step2: click on design
Design:

Step3: Double click on button and write a code


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace pract1c
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int num, counter, ans;
num = Convert.ToInt32(TextBox1.Text);
for (counter = 2; counter <= num / 2; counter++)
{
if ((num % counter) == 0)
break;
}
if (num == 1)
{
Label2.Text = num + "is not prime nor composite";
}
else if (counter < (num / 2))
{
Label2.Text = num + "is not prime";
}
else
{
Label2.Text = num + "is prime number";
}
}
}
}
Step4: Run the Project.
OUTPUT:
Practical No. 2A
Step1:Create Web Form
Solution Explorer>right click on project name>Add>new WebForm
file>ok
Step2: click on design
Design:
Step3: Double click on every button and write a code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace p2A
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int valueType = 45;
object boxed = valueType;
Label1.Text = "Boxing: Value type " + valueType + " is boxed into Object " + boxed;
}
protected void Button2_Click(object sender, EventArgs e)
{
object boxed = 20;
int valueType = (int)boxed;
Label1.Text = "Unboxing: Object " + boxed + " is Unboxed into valueType " + valueType;
}
}
}
Step4: Run the Project.
OUTPUT:

Practical No.2B

Step1:Create Web Form


Solution Explorer>right click on project name>Add>new WebForm
file>ok
Step2: click on design
Design:
Step3: Double click on every button and write a code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace P2B
{
public partial class WebForm1 : System.Web.UI.Page
{
public delegate int Calculation(int a, int b);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int num1 = Convert.ToInt32(TextBox1.Text);
int num2 = int.Parse(TextBox2.Text);

Calculation cal = Add;


int addition = cal(num1, num2);
Label3.Text = "Addition: " + addition.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
int num1 = Convert.ToInt32(TextBox1.Text);
int num2 = int.Parse(TextBox2.Text);
Calculation cal = Sub;
int subtract = cal(num1, num2);
Label3.Text = "Subtraction: " + subtract.ToString();
}
public int Add(int a, int b)
{
return a + b;
}
public int Sub(int a, int b)
{
return a - b;
}
}
}
Step4: Run the Project.
OUTPUT:
Practical No. 2C

Step1:Create Web Form

Solution Explorer>right click on project name>Add>new WebForm


file>ok
Step2: click on design

Design:
Step3: Double click on every button and write a code
Code:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public class shape
{
public int x, y, z;
public void getSide(int length, int breadth, int width)
{
x = length;
y = breadth;
z = width;
}
}
public interface IPolygon
{
int calCulateArea();
}
public interface IVolume
{
int getVolume();
}
class Rectangle : shape, IPolygon, IVolume
{
public int calCulateArea()
{
return (x * y);
}
public int getVolume()
{
return (x * y * z);
}
}
namespace P2C
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Rectangle r1 = new Rectangle();
int result;
r1.getSide(24, 67, 8);
result = r1.calCulateArea();
Label1.Text = "Area=" + result;

int c;
c = r1.getVolume();
Label2.Text = "Volume=" + c;
}
}
}

Step4: Run the WebForm.


OUTPUT:

Practical No.4A
Step 1: Create Web form
Design:

Step 2: Add Validation controls


1) Required Field validation control
Design:

Error message after run


Solution of error:
Practical no.4B

Step 1: Create Web form


Step 2: Add ADRotator
Design:

Step3: To create XML file


Solution Explorer>right click on project name>Add>new item>XML
file>ok
Step4:Add images
Solution Explorer>right click on project name>Add>Existing item>Select
location (if image is on Desktop select desktop set as image(png....))
Select image >ok
images are added

Step 3: Code
<?xml version="1.0" encoding="utf-8" ?>

<Advertisements>

<Ad>

<ImageUrl>collegeimg.jpg</ImageUrl>

<NavigateUrl>https://sdsmcollege.in/</NavigateUrl>

<AlernateText>SONOPANT DANDEKAR COLLEGE, PALGHAR</AlernateText>

<Keyword>college</Keyword>

</Ad>

<Ad>

<ImageUrl>Law.jpeg</ImageUrl>

<NavigateUrl>https://sdsmlawcollege.in/</NavigateUrl>

<AlernateText>SONOPANT DANDEKAR COLLEGE, PALGHAR</AlernateText>

<Keyword>Law college</Keyword>

</Ad>

</Advertisements>
Step4: Run the WebForm.

OUTPUT:
Reload page :

Click on image:
Practical 4C
Step1: Solution Explorer > Add > new item > select web forms user
control > rename it as footer

Step 2: Solution Explorer> Add > new item> web form > create design
> to add footer .ascx file just drag and drop it on your design

Step 3: Double click on button > write code


Output:

Practical no. 5A
Step 1: Solution Explorer>Add>new item>Web form
Design: Toolbox>select each >Menu , SiteMapPath,SiteMapDatasource

Step 2: Solution Explorer>Add>new item>Web form


Design: Toolbox>SiteMapPath

To add the text


Step 3:Solution Explorer>Add>new item>Web form
Design: Toolbox>SiteMapPath
Step 4:Solution Explorer>Add>new item>SiteMap

Go to WebForm1.aspx >Run
Output:

Practical no.5B
Step 1:to add master page
Solution Explorer>Add>new item>Web forms Master Page
Step 2:to add style sheet
Solution Explorer>Add>new item>Style sheet

Step 3:To give reference of style sheet


Open site1.Master>in right side select stylesheet1.css drag and drop it
to body of site1.Master file>check body of that file

Step 4:to add Skin file


Solution Explorer>Add>new item>Web forms skin file >yes
Step 5:To add web form with master page
Solution Explorer>Add>new item>select Web forms with Master Page
>choose your existing file > ok
Design:

Then add this:

Step 6: repeat step 5


Step 7:
Run WebForm1.aspx

Practical no.5C
1) View State
Step 1: Add web form
Step 2:Create Design
Step 3: In source
Code:

Output:
2)Query String
Step 1:Add new Web form
Step 2: Design

Step 3:Add one more web form and design it

Step 4:Add code in WebForm2.aspx.cs


Step 5:WebForm3.aspx
Right click >select >view code

Output:
—--------------------------------------------------------------------------------------------
3)Dropdown list
Step 1:Add new Web form
Step 2: Design

Tick mark the popup


Edit items> Add >change text>ok

Double Click on dropdown list and Write code :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace P5C
{
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;
form1.Style["background-color"] = DropDownList1.SelectedValue;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
form1.Style["background-color"] = DropDownList1.SelectedValue;
HttpCookie cookie = new HttpCookie("BackgroundColor");
cookie.Value = DropDownList1.SelectedValue;
cookie.Expires = DateTime.Now.AddMilliseconds(20);
Response.SetCookie(cookie);
}
}
}

Run webForm:
OUTPUT:

—--------------------------------------------------------------------------------------------
4)Application and session state
Step 1:Add new Web form
Step 2: Design
1 button>2 Labels

Step3:Solution Explorer>Add>new item>Global Application class>ok


code:Global.asax.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace y5c
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Application.Add("myax", 0);
}

protected void Session_Start(object sender, EventArgs e)


{
Session.Add("mysx", 0);
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}

Code:Webform1.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

protected void Button1_Click(object sender, EventArgs e)


{
Label2.Text = "";
int x;
x = int.Parse(Application["myax"].ToString());
x++;
Application["myax"] = x;
Label2.Text = "<br>Application" + x;
x = int.Parse(Session["mysx"].ToString());
x++;
Session["mysx"] = x;
Label2.Text = Label2.Text + "<br>Session" + x;
}

}
}

Run WebForm
OUTPUT

Practical No. 6A
Step 1:Add new Web form
Step 2: Design
Step3: Double click on button and write a code
Code:WebForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace P6A
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie c1 = new HttpCookie("creator");
c1.Value = "Yash";

Response.Cookies.Add(c1);
String author = Response.Cookies["creator"].Value;

Label1.Text = author;

Response.Cookies["computer"].Expires = DateTime.Now.AddDays(1);
}

protected void Button1_Click(object sender, EventArgs e)


{
Label3.Text = "";

if (CheckBoxList1.Items[0].Selected)

Response.Cookies["computer"]["apple"] = "apple";

if (CheckBoxList1.Items[1].Selected)

Response.Cookies["computer"]["dell"] = "dell";

if (CheckBoxList1.Items[2].Selected)

Response.Cookies["computer"]["lenovo"] = "Lenovo";

if (CheckBoxList1.Items[3].Selected)

Response.Cookies["computer"]["acer"] = "acer";

if (CheckBoxList1.Items[4].Selected)

Response.Cookies["computer"]["sony"] = "sony";

if (CheckBoxList1.Items[4].Selected)

Response.Cookies["computer"]["wipro"] = "wipro";

if (Request.Cookies["computer"].Values.ToString() != null)

{
if (Request.Cookies["computer"]["apple"] != null)

Label3.Text += Request.Cookies["computer"]["apple"] + "";

if (Request.Cookies["computer"]["dell"] != null)
Label3.Text += Request.Cookies["computer"]["dell"] + "";

if (Request.Cookies["computer"]["lenovo"] != null)

Label3.Text += Request.Cookies["computer"]["Lenovo"] + "";

if (Request.Cookies["computer"]["acer"] != null)

Label3.Text += Request.Cookies["computer"]["acer"] + "";

if (Request.Cookies["computer"]["sony"] != null)

Label3.Text += Request.Cookies["computer"]["sony"] + "";

if (Request.Cookies["computer"]["wipro"] != null)

Label3.Text += Request.Cookies["computer"]["wipro"] + "";

else
Label3.Text = "Please select your choice";

Response.Cookies["computer"].Expires = DateTime.Now.AddDays(1);
}
}
}
}

OutPut:
Practical No. 6B
Step 1:Add new Web form
Step 2: Design

Step 3:Add new Web form and its Design

Step 4: code in WebForm1.aspx.cs file


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace P6B
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected bool Authenticate(String uname, String pass)
{
if (uname == "rohit")
{
if (pass == "HITMAN45") return true;
}
if (uname == "riya")
{
if (pass == "r123") return true;
}
return false;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Authenticate(TextBox1.Text, TextBox2.Text))
{
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, CheckBox1.Checked);
Session["username"] = TextBox1.Text;
Response.Redirect("WebForm2.aspx");
}
else
{
Response.Write("Invalid user name or password.");
}
}
}
}

Step 5:In WebForm2 to add code>right click on label 2 >view


code>add code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace P6B
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["username"] !=null)
{
Label1.Text = Session["username"].ToString();
}
}
}
}

Step6:Solution Explorer > open Web config


code:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<authentication mode ="Forms">
<forms loginUrl="WebForm1.aspx" />
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" warningLevel="4"
compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" warningLevel="4"
compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\
&quot; /optionInfer+" />
</compilers>
</system.codedom>
</configuration>

Output:

Practical No. 7
Step 1:Add new Web form
Step 2: Design

Step 3: Right click on label >view code


code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace P7A
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
throw new UserDefinedException("New User Defined Exception");
}
catch (Exception ex)
{
Label1.Text = "Exception caught here" + ex.ToString();
}
Label2.Text = "Final Statement that is executed";
}
class UserDefinedException : Exception
{
public UserDefinedException(string str)
{
Console.WriteLine("User defined exception");
}
}
class HandledException
{
public static void Main()
{
}
}
}
}

Output:

Practical No. 8
Step 1:Add new Web form
Step 2: Design
in design take scrip manager then update panel in that take one
button and label
then outside update panel take one button and label

step 3:Double click on both buttons


code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace p8
{
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 form panel"+time;
Label2.Text= "Showing time form outside"+time;
}
protected void Button2_Click(object sender, EventArgs e)
{
String time = DateTime.Now.ToLongTimeString();
Label1.Text = "Showing time form panel" + time;
Label2.Text = "Showing time form outside" + time;
}
}
}

Output:

You might also like