Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Dotnet Lab Programs

The document outlines various ASP.Net applications, including a job seeker detail form, data retrieval and display in a table format, email validation form with controls, and applications using data grid and data list controls to access SQL Server data. It also includes source code snippets for each application and describes the design pages and output screens. Additionally, it mentions the creation of an employee pay slip using SQL connection.

Uploaded by

suriyapriya471
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Dotnet Lab Programs

The document outlines various ASP.Net applications, including a job seeker detail form, data retrieval and display in a table format, email validation form with controls, and applications using data grid and data list controls to access SQL Server data. It also includes source code snippets for each application and describes the design pages and output screens. Additionally, it mentions the creation of an employee pay slip using SQL connection.

Uploaded by

suriyapriya471
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 52

1. Design ASP.

Net web form using Html Server


Controls to enter job seeker’s detail.

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
publicpartialclass_Default : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
string user = "thilaga";
string pwd = "thilaga";
if ((TextBox1.Text==user ) && (TextBox2.Text ==pwd ))
{
Response.Redirect ("default2.aspx");
}
else
{
Label1.Text = "INVALID USERNAME AND PASSWORD"
}
}

DEPARTMENT OF COMPUTER SCIENCE


}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
publicpartialclassDefault2 : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
Label1.Text = "NAME IS:" + TextBox1.Text;
Label2.Text = "DOB:" + TextBox2.Text;
if (RadioButton1.Checked)
{
Label3.Text = "GENTER IS :MALE";
}
else
{
Label3.Text = "GENTER IS:FEMALE";
}
Label4.Text ="QUALIFICATION IS:"+DropDownList1.Text ;
if(CheckBox1.Checked )

DEPARTMENT OF COMPUTER SCIENCE


{
Label5.Text ="LANGUAGE Know Are: c,";
}
if(CheckBox2.Checked )
{
Label6.Text ="c++";
}
if(CheckBox3.Checked )
{
Label7.Text =" java";
}
if(CheckBox4.Checked )
{
Label8.Text =" dotnet";
}
if(CheckBox5.Checked )
{
Label9.Text =" python";
}
Label10.Text = "PHONE NUMBER IS:" + TextBox3.Text;
Label11.Text = "SUCESS FULLY SUBMITES YOUR APPLICATIONS";
}
}

Design Page:
Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


DEPARTMENT OF COMPUTER SCIENCE
2. Write an ASP.Net application to retrieve form data
and display it the client browser in a table format.

DEPARTMENT OF COMPUTER SCIENCE


Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
publicpartialclass_Default : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
string name = TextBox1.Text;
string email = TextBox2.Text;
string ph = TextBox3.Text;
Table datatable = newTable();
datatable.BorderWidth = 1;
datatable.CellPadding = 5;
TableRow headerRow = newTableRow();
headerRow.Cells.Add(CreateCell("Field", true));
headerRow.Cells.Add(CreateCell("Value", true));
TableRow headerrow = newTableRow();
datatable.Rows.Add(CreateRow("NAME", name));
datatable.Rows.Add(CreateRow("Email", email));
datatable.Rows.Add(CreateRow("phone", ph));
PlaceHolderTABLE.Controls.Add(datatable);

DEPARTMENT OF COMPUTER SCIENCE


}
privateTableRow CreateRow(string field, string value)
{
TableRow row = newTableRow();
row.Cells.Add(CreateCell(field));
row.Cells.Add(CreateCell(value));
return row;
}
privateTableCell CreateCell(string text, bool isHeader = false)
{
TableCell cell = isHeader ? newTableHeaderCell() : newTableCell();
cell.Text = text;
return cell;
}
}

Design Page:
Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


3. Apply appropriate validation techniques in E-Mail
registration form using validation controls.

DEPARTMENT OF COMPUTER SCIENCE


Source Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
font-family: "Arial Black";
font-size: xx-large;
font-weight: normal;
}
.style3
{
width: 83%;
height: 398px;
margin-left: 5px;
}
.style4
{
height: 28px;
}
.style5
{
height: 40px;
}
</style>
</head>
<body style="font-family: 'Bahnschrift SemiCondensed'">
<form id="form1" runat="server">
<div>
<h1 style="width: 803px; margin-left: 5px">
<span class="style1">EMAIL VALIDATION FORM</span></h1>
</div>
<table class="style3">
<tr>
<td>
STUDENT NAME:
<asp:TextBox ID="TextBox1" runat="server" Width="118px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="*please enter your name"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>

DEPARTMENT OF COMPUTER SCIENCE


<td>
FIRST NAME:
<asp:TextBox ID="TextBox2" runat="server" Width="120px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2" ErrorMessage="*please enter first your name"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td>
LAST NAME:
<asp:TextBox ID="TextBox3" runat="server" Width="119px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="TextBox3" ErrorMessage="*please enter your last name"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td>
AGE:
<asp:TextBox ID="TextBox4" runat="server" Width="118px"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox4" ErrorMessage="*age should be 18 to 35"
ForeColor="Red" MaximumValue="35"
MinimumValue="18"></asp:RangeValidator>
</td>
<td>
</td>
</tr>
<tr>
<td class="style5">
EMAIL ID:
<asp:TextBox ID="TextBox5" runat="server" Width="117px"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox5" ErrorMessage="*(a-z,A-Z,0-9,@ accept there
only)"
ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></
asp:RegularExpressionValidator>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td>

DEPARTMENT OF COMPUTER SCIENCE


PASSWORD :
<asp:TextBox ID="TextBox6" runat="server" Width="122px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="TextBox6"
ErrorMessage="*(8 characters only,include alphabets,numbers and special
symbols)"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td>
CONFORM PASSWORD:
<asp:TextBox ID="TextBox7" runat="server" Width="119px"></asp:TextBox>
<asp:CompareValidator runat="server" ControlToCompare="TextBox6"
ControlToValidate="TextBox7" ErrorMessage="*not match the password"
ForeColor="Red"></asp:CompareValidator>
</td>
<td>
</td>
</tr>
<tr>
<td>
SELECT COUNTRY:
<asp:TextBox ID="TextBox8" runat="server" Width="119px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="TextBox8" ErrorMessage="*please enter your country"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" style="margin-left: 251px"
Text="SUBMIT" Width="96px" />
</td>
<td>
</td>
</tr>
<tr>
<td class="style4">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
</td>
<td class="style4">
</td>
</tr>
</table>
</form>

DEPARTMENT OF COMPUTER SCIENCE


</body>
</html>

Design Page:
Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


4. Create an application using Data grid control to
access information’s from table in SQL server.

DEPARTMENT OF COMPUTER SCIENCE


Source Code:
<
%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_De
fault"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0
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>
<center><h2>Data Grid Control to Access Information’s from Table in SQL Server</h2>
<br/>
<br/>
<br/>
<br/>
<asp:GridViewID="GridView1"runat="server"DataSourceID="AccessDataSource1"
AutoGenerateColumns="False"CaptionAlign="Right"DataKeyNames="ID">
<Columns>
<asp:BoundFieldDataField="ID"HeaderText="ID"InsertVisible="False"
ReadOnly="True"SortExpression="ID"/>
<asp:BoundFieldDataField="NAME"HeaderText="NAME"SortExpression="NAME"/>
<asp:BoundFieldDataField="PHONE"HeaderText="PHONE"SortExpression="PHONE"/>
<asp:BoundFieldDataField="EMAILID"HeaderText="EMAILID"
SortExpression="EMAILID"/>
<asp:BoundFieldDataField="ADDRESS"HeaderText="ADDRESS"
SortExpression="ADDRESS"/>
</Columns>

DEPARTMENT OF COMPUTER SCIENCE


</asp:GridView>
<asp:AccessDataSourceID="AccessDataSource1"runat="server"
DataFile="~/Database1.mdb"
SelectCommand="SELECT [ID], [NAME], [PHONE], [EMAILID], [ADDRESS] FROM
[GRIDVIEW]">
</asp:AccessDataSource>
</center></div>
</form>
</body>
</html>

Design Page:
Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


5. Create an application using Data list control to
access information’s from table in SQL server and
display the result in neat format.

DEPARTMENT OF COMPUTER SCIENCE


Source Code:
<
%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_De
fault"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0
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>
<CENTER><h2> DATA LIST VIWE CONTROLS </H2>
<p>
<asp:DataListID="DataList1"runat="server"CellPadding="4"DataKeyField="ID1"
DataSourceID="SqlDataSource1"ForeColor="#333333"Width="289px">
<AlternatingItemStyleBackColor="White"/>
<FooterStyleBackColor="#990000"Font-Bold="True"ForeColor="White"/>
<HeaderStyleBackColor="#990000"Font-Bold="True"ForeColor="White"/>
<ItemStyleBackColor="#FFFBD6"ForeColor="#333333"/>
<ItemTemplate>
ID1:
<asp:LabelID="ID1Label"runat="server"Text='<%# Eval("ID1") %>'/>
<br/>
ID:
<asp:LabelID="IDLabel"runat="server"Text='<%# Eval("ID") %>'/>
<br/>
NAME:
<asp:LabelID="NAMELabel"runat="server"Text='<%# Eval("NAME") %>'/>

DEPARTMENT OF COMPUTER SCIENCE


<br/>
DOTNET:
<asp:LabelID="DOTNETLabel"runat="server"Text='<%# Eval("DOTNET") %>'/>
<br/>
OOAD:
<asp:LabelID="OOADLabel"runat="server"Text='<%# Eval("OOAD") %>'/>
<br/>
MOBILE_COMPUTING:
<asp:LabelID="MOBILE_COMPUTINGLabel"runat="server"
Text='<%# Eval("MOBILE_COMPUTING") %>'/>
<br/>
IOT:
<asp:LabelID="IOTLabel"runat="server"Text='<%# Eval("IOT") %>'/>
<br/>
OS:
<asp:LabelID="OSLabel"runat="server"Text='<%# Eval("OS") %>'/>
<br/>
<br/>
</ItemTemplate>
<SelectedItemStyleBackColor="#FFCC66"Font-Bold="True"ForeColor="Navy"/>
</asp:DataList>
</p>
<p>&nbsp;</p>
<p>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT [ID1], [ID], [NAME], [DOTNET], [OOAD], [MOBILE
COMPUTING] AS MOBILE_COMPUTING, [IOT], [OS] FROM [listview]">
</asp:SqlDataSource>

DEPARTMENT OF COMPUTER SCIENCE


</p>
</CENTER></div>
</form>
</body>
</html>

Design Page:
Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


6. Prepare employee pay slip using SQL connection.

DEPARTMENT OF COMPUTER SCIENCE


Source Code:
<%@PageTitle="Home
Page"Language="C#"MasterPageFile="~/Site.master"AutoEventWireup="true"
CodeFile="Default.aspx.cs"Inherits="_Default"%>
<scriptrunat="server">
</script>
<asp:ContentID="HeaderContent"runat="server"ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:ContentID="BodyContent"runat="server"ContentPlaceHolderID="MainContent">
<p>
<asp:LabelID="Label1"runat="server"Text="EMPLOYEE ID"></asp:Label>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label2"runat="server"Text="NAME"></asp:Label>
<asp:TextBoxID="TextBox12"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label3"runat="server"Text="ADDRESS"></asp:Label>
<asp:TextBoxID="TextBox3"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label5"runat="server"Text="PHONE NO"></asp:Label>
<asp:TextBoxID="TextBox4"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label6"runat="server"Text="BASIC PAY"></asp:Label>
<asp:TextBoxID="TextBox5"runat="server"></asp:TextBox>
</p>

DEPARTMENT OF COMPUTER SCIENCE


<p>
<asp:LabelID="Label7"runat="server"Text="HRA"></asp:Label>
<asp:TextBoxID="TextBox6"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label8"runat="server"Text="DA"></asp:Label>
<asp:TextBoxID="TextBox7"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label9"runat="server"Text="PF"></asp:Label>
<asp:TextBoxID="TextBox8"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label10"runat="server"Text="GROSS PAY"></asp:Label>
<asp:TextBoxID="TextBox9"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label11"runat="server"Enabled="False"Text="DEDUCTION"></
asp:Label>
<asp:TextBoxID="TextBox10"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label12"runat="server"Text="NET PAY"></asp:Label>
<asp:TextBoxID="TextBox11"runat="server"></asp:TextBox>
</p>
<p>
<asp:LabelID="Label13"runat="server"Text="Label"></asp:Label>
</p>
<p>
<asp:ButtonID="Button1"runat="server"onclick="Button1_Click"Text="INSERT"/>

DEPARTMENT OF COMPUTER SCIENCE


<asp:ButtonID="Button2"runat="server"Text="DELETE"onclick="Button2_Click"/>
<asp:ButtonID="Button3"runat="server"onclick="Button3_Click"
style="height: 26px"Text="clear"/>
<asp:ButtonID="Button4"runat="server"onclick="Button4_Click"
Text="calculate"/>
</p>
<p>
<asp:GridViewID="GridView1"runat="server"DataSourceID="SqlDataSource1"
AutoGenerateColumns="False"DataKeyNames="EMPLOYEEID"AllowPaging="True">
<Columns>
<asp:BoundFieldDataField="EMPLOYEEID"HeaderText="EMPLOYEEID"
InsertVisible="False"ReadOnly="True"SortExpression="EMPLOYEEID"/>
<asp:BoundFieldDataField="NAME"HeaderText="NAME"SortExpression="NAME"/>
<asp:BoundFieldDataField="ADDRESS"HeaderText="ADDRESS"
SortExpression="ADDRESS"/>
<asp:BoundFieldDataField="PHONE_NO"HeaderText="PHONE_NO"
SortExpression="PHONE_NO"/>
<asp:BoundFieldDataField="BASIC_PAY"HeaderText="BASIC_PAY"
SortExpression="BASIC_PAY"/>
<asp:BoundFieldDataField="HRA"HeaderText="HRA"SortExpression="HRA"/>
<asp:BoundFieldDataField="DA"HeaderText="DA"SortExpression="DA"/>
<asp:BoundFieldDataField="PF"HeaderText="PF"SortExpression="PF"/>
<asp:BoundFieldDataField="GROSS_PAY"HeaderText="GROSS_PAY"
SortExpression="GROSS_PAY"/>
<asp:BoundFieldDataField="DEDUCTION"HeaderText="DEDUCTION"
SortExpression="DEDUCTION"/>
<asp:BoundFieldDataField="NETPAY"HeaderText="NETPAY"
SortExpression="NETPAY"/>
</Columns>

DEPARTMENT OF COMPUTER SCIENCE


</asp:GridView>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"
ConnectionString="<%$ ConnectionStrings:empConnectionString %>"
ProviderName="<%$ ConnectionStrings:empConnectionString.ProviderName %>"
SelectCommand="SELECT [EMPLOYEEID], [NAME], [ADDRESS], [PHONE NO] AS
PHONE_NO, [BASIC PAY] AS BASIC_PAY, [HRA], [DA], [PF], [GROSS PAY] AS
GROSS_PAY, [DEDUCTION], [NETPAY] FROM [Table1]">
</asp:SqlDataSource>
</p>
</asp:Content>

Default.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.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Web.UI.WebControls.WebParts;
using System.ComponentModel;
using System.Data;
publicpartialclass_Default : System.Web.UI.Page
{
OleDbConnection con;
OleDbCommand com;
protectedvoid Page_Load(object sender, EventArgs e)
{
con = newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=F:/emp.mdb");

DEPARTMENT OF COMPUTER SCIENCE


}
protectedvoid Button1_Click(object sender, EventArgs e)
{
con.Open();
com = newOleDbCommand("insert into Table1 values(' " + TextBox1.Text + " ',' " +
TextBox12.Text + " ',' " + TextBox3.Text + " ',' " + TextBox4.Text + " ',' " + TextBox5.Text
+ " ',' " + TextBox6.Text + " ',' " + TextBox7.Text + " ',' " + TextBox8.Text + " ',' " +
TextBox9.Text + " ',' " + TextBox10.Text + " ',' " + TextBox11.Text + " ')", con);
com.ExecuteNonQuery();
Label13.Text = "RECORD INSERTED";
con.Close();
}
protectedvoid Button2_Click(object sender, EventArgs e)
{
con.Open();
com = newOleDbCommand("delete from Table1 where NAME='" + TextBox12.Text + "'",
con);
com.ExecuteNonQuery();
Label13.Text = "RECORD DELETED";
con.Close();
}
protectedvoid Button3_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox12.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";

DEPARTMENT OF COMPUTER SCIENCE


TextBox9.Text = "";
TextBox10.Text = "";
TextBox11.Text = "";
}
protectedvoid Button4_Click(object sender, EventArgs e)
{
TextBox9.Text = (Convert.ToInt32(TextBox6.Text) + Convert.ToInt32(TextBox7.Text) +
Convert.ToInt32(TextBox8.Text)).ToString();
TextBox11.Text = (Convert.ToInt32(TextBox9.Text) -
Convert.ToInt32(TextBox10.Text)).ToString();
}
}

Design Page:
Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


MICROSOFT ACCESS DATABASE:

Design page2:

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


7. Design a banking application for doing deposit,
withdrawal and balance enquiry.

Source Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"


Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<CENTER>
<H1> BANK APPLICATION</H1>
<br />
<br />
ENTER YOUR NAME:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<br />

DEPARTMENT OF COMPUTER SCIENCE


<br />
ENTER YOUR PIN:
<asp:TextBox ID="TextBox2" runat="server" style="margin-left: 0px"
TextMode="Password"></asp:TextBox>
<br />
<br />
<br />
<br />
ENTER YOUR AMOUNT:
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<br />
<br />
<br />
<br />
<asp:RadioButton ID="DEPOSIT" runat="server" AutoPostBack="True"
oncheckedchanged="DEPOSIT_CheckedChanged" Text="DEPOSIT" />
<asp:RadioButton ID="WITHDRAW" runat="server" AutoPostBack="True"
oncheckedchanged="WITHDRAW_CheckedChanged" Text="WITHDRAW" />
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="BALANVE ENQ" />
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label" BorderColor="#3333FF"
BorderStyle="Double" ForeColor="#FF3300"></asp:Label>
<br />
<br />
<br />
<br />
<br />
<br />
</CENTER>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page

DEPARTMENT OF COMPUTER SCIENCE


{

private static decimal accountBalance = 1000;

protected void Page_Load(object sender, EventArgs e)


{
if (!IsPostBack)
{
Label1.Text = "Welcome! Your balance is $" + accountBalance;
}
}
protected void DEPOSIT_CheckedChanged(object sender, EventArgs e)
{
accountBalance += (Convert.ToInt32(TextBox3.Text)) ;
Label1.Text = "$Deposit successful! New balance $:" + accountBalance;
}
protected void WITHDRAW_CheckedChanged(object sender, EventArgs e)
{
accountBalance -= (Convert.ToInt32(TextBox3.Text));
Label1.Text = "$Deposit successful! New balance $:" + accountBalance;
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "$Your current balance is $:" + accountBalance;
}
}

Design Page:

Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


DEPARTMENT OF COMPUTER SCIENCE
8. Demonstrate the file upload control usage.

DEPARTMENT OF COMPUTER SCIENCE


Source Code:

<
%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_De
fault"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0
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>
<center><H2> FILE UPLOAD CONTROLS </H2>
<br/>
<br/>
<br/>
<asp:FileUploadID="FileUpload1"runat="server"/>
<asp:ButtonID="btnUpload"runat="server"onclick="btnUpload_Click"
Text="UPLOAD"/>
<br/>
<br/>
<asp:LabelID="lblMessage"runat="server"></asp:Label>
</div>
</center></form>
</body>
</html>

using System;
using System.Collections.Generic;

DEPARTMENT OF COMPUTER SCIENCE


using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
publicpartialclass_Default : System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid btnUpload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
try
{
string uploadFolder = Server.MapPath("~/Uploads/");
if (!Directory.Exists(uploadFolder))
{
Directory.CreateDirectory(uploadFolder);
}
string filePath = uploadFolder + Path.GetFileName(FileUpload1.FileName);
FileUpload1.SaveAs(filePath);
lblMessage.Text = "File uploaded successfully: " + FileUpload1.FileName;
lblMessage.ForeColor = System.Drawing.Color.Green;
}
catch (Exception ex)
{
lblMessage.Text = "File upload failed: " + ex.Message;

DEPARTMENT OF COMPUTER SCIENCE


lblMessage.ForeColor = System.Drawing.Color.Red;
}
}
else
{
lblMessage.Text = "Please select a file to upload.";
lblMessage.ForeColor = System.Drawing.Color.Red;
}
}
}

Design Page:

Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


DEPARTMENT OF COMPUTER SCIENCE
9. Design a web page to display the advertisements
using Ad Rotator Control.

DEPARTMENT OF COMPUTER SCIENCE


Source Code:

<?xmlversion="1.0"encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>girl.jpg</ImageUrl>
<NavigateUrl></NavigateUrl>
<AlternateText>Ad1</AlternateText>
</Ad>
<Ad>
<ImageUrl>flow.jpg</ImageUrl>
<NavigateUrl></NavigateUrl>
<AlternateText>Ad2</AlternateText>
</Ad>
<Ad>
<ImageUrl>flow1.jpg</ImageUrl>
<NavigateUrl></NavigateUrl>
<AlternateText>Ad3</AlternateText>
</Ad>
</Advertisements>
<
%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_De
fault"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0
Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<bodystyle="margin-left: 10px">

DEPARTMENT OF COMPUTER SCIENCE


<formid="form1"runat="server">
<div>
<center><h2>Display the Advertisements using Ad Rotator Control. </h2>
<asp:AdRotatorID="AdRotator1"runat="server"AdvertisementFile="~/XMLFile.xml"
BorderStyle="Solid"/>
</center>
</div>
</form>
</body>
</html>

Design Page:

Default.aspx

DEPARTMENT OF COMPUTER SCIENCE


Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


10. Demonstrate the Data List Control.

Source Code:

using System;

DEPARTMENT OF COMPUTER SCIENCE


using System.Collections.Generic;
using System.Web.UI;
namespace DataListDemo
{
public partial class Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDataList();
}
}
private void BindDataList()
{
List<Product> products = new List<Product>
{
new Product { ProductName = "Laptop", Price = 800 },
new Product { ProductName = "Smartphone", Price = 500 },
new Product { ProductName = "Tablet", Price = 300 },
new Product { ProductName = "Headphones", Price = 100 },
new Product { ProductName = "Smartwatch", Price = 200 }
};
dlProducts.DataSource = products;
dlProducts.DataBind();
}
}
public class Product
{
public string ProductName { get; set; }
public int Price { get; set; }

DEPARTMENT OF COMPUTER SCIENCE


Design Page:

Default.aspx

Output Screen:

DEPARTMENT OF COMPUTER SCIENCE


DEPARTMENT OF COMPUTER SCIENCE

You might also like