Professional Documents
Culture Documents
Div - B
Roll no -100
TYBCA
WAD Practical 2
August 02, 2022
Program 1 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "1")
{
Label1.Text = "15.00";
}
else if (DropDownList1.SelectedValue=="2")
2 Dev shah Roll no- 100 Div - B
{
Label1.Text="80.00";
}
else if(DropDownList1.SelectedValue=="3")
{
Label1.Text="45.00";
}
else if (DropDownList1.SelectedValue == "4")
{
Label1.Text = "30.00";
}
else
{
Label1.Text = "0.00";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int A;
A = Convert.ToInt32(TextBox1.Text);
double b;
b = Convert.ToDouble(Label1.Text);
double total = A*b;
Label2.Text = total.ToString();
}
}
3 Dev shah Roll no- 100 Div - B
Output 1:
Program 2 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
4 Dev shah Roll no- 100 Div - B
Output 2:
Program 3 :
using System;
5 Dev shah Roll no- 100 Div - B
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Response.Write(li.Text);
Response.Write("<br/>");
}
}
}
protected void CheckBoxList2_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
Output 3:
7 Dev shah Roll no- 100 Div - B
Program 4 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
}
Output 4:
Program 5:
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;
{
ddlCity.Items.Clear();
ddlCity.Items.Insert(0, new ListItem("--Select--", "0"));
}
}
catch (Exception ex)
{
//Printing any exception if occcured.
Response.Write("Error occured: " + ex.Message.ToString());
}
finally
{
//Close the connection
con.Close();
}
}
protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
int StateId = Convert.ToInt32(ddlState.SelectedValue);
//Select all Cities corresponding to the selected State
SqlDataAdapter adp = new SqlDataAdapter("select * from Tbl_City where
State_ID_Fk=" + StateId, con);
DataSet ds = new DataSet();
adp.Fill(ds);
ddlCity.DataSource = ds;
ddlCity.DataTextField = "City_Name";
11 Dev shah Roll no- 100 Div - B
ddlCity.DataValueField = "City_id_pk";
ddlCity.DataBind();
ddlCity.Items.Insert(0, new ListItem("--Select--", "0"));
}
catch (Exception ex)
{
Response.Write("Error occured : " + ex.Message.ToString());
}
finally
{
con.Close();
}
}
}
catch (Exception ex)
{
Response.Write("Error occured : " + ex.Message.ToString());
}
finally
{
con.Close();
}
}
Output 5:
Program 6:
using System;
using System.Collections.Generic;
using System.Linq;
13 Dev shah Roll no- 100 Div - B
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
}
protected void Button1_Click(object sender, EventArgs e)
{
String str;
str = Server.MapPath("images");
string fileextension = Path.GetExtension(FileUpload1.FileName);
if (FileUpload1.HasFile == true)
{
if (fileextension.ToLower() != ".jpeg" &&
fileextension.ToLower() != ".jpg")
{
Label1.Text = "Only .jpg and .jpeg file allowed...";
}
else
{
int size = FileUpload1.PostedFile.ContentLength;
if (size > 10000000000)
14 Dev shah Roll no- 100 Div - B
{
Label1.Text = "File size exceeds 1 KB";
}
else
{
str = str + "\\" + FileUpload1.FileName;
FileUpload1.SaveAs(str);
Label1.Text = "File has been succesfully uploaded" + "uploaded at" + str;
Image1.ImageUrl = "Images\\" + FileUpload1.FileName;
}
}
}
else
{
Label1.Text = "No file selected... Please select File...";
}
}
}
Output 6:
15 Dev shah Roll no- 100 Div - B
Program 7:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Button1_Click(object sender, EventArgs e)
{
HttpCookie coke = new HttpCookie("userinfo");
coke["NO"] = TextBox1.Text;
coke["Name"] = TextBox2.Text;
coke["price"] = TextBox3.Text;
coke["quantity"] = TextBox4.Text;
Response.Cookies.Add(coke);
Response.Redirect("default2.aspx");
}
}
16 Dev shah Roll no- 100 Div - B
Output 7:
Program 8:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
17 Dev shah Roll no- 100 Div - B
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
18 Dev shah Roll no- 100 Div - B
Output 8 :
Program 9:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
19 Dev shah Roll no- 100 Div - B
</div>
</form>
</body>
</html>
Xml code:
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>1.jpg</ImageUrl>
<AlternateText>
</AlternateText>
<NavigateUrl>http://www.google.com</NavigateUrl>
</Ad>
<Ad>
<ImageUrl>2.jpg</ImageUrl>
<AlternateText></AlternateText>
<NavigateUrl></NavigateUrl>
</Ad>
<Ad>
<ImageUrl>3.jpg</ImageUrl>
<AlternateText></AlternateText>
<NavigateUrl></NavigateUrl>
</Ad>
20 Dev shah Roll no- 100 Div - B
</Advertisements>
Output 9:
Program 10:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
Label1.Text = Calendar1.SelectedDate.ToString();
}
}
Output 10: