.NET Programming(ASP.
NET)
Program LIST
1. Create an exposure of Web application and tools.
2. Implement the HTML Controls.
3. Implement the Server Control.
4. Web application using Web Controls.
5. Web application using list Controls.
6. Web page design using rich control. Validate user input using validation control.
7. Web application using data controls.
8. Database application to perform insert, update and delete operations.
9. Data base application using data controls to perform insert, delete, edit operation.
10. Data base application using data controls to perform paging and sorting operation.
11. Implement the XML Classes.
12. Online examination using [Link] controls.
PROGRAM 1: Create an exposure of Web [Link]
application and tools using System;
<%@ Page Language="C#" using [Link];
AutoEventWireup="true" using [Link];
CodeBehind="[Link]" using [Link];
Inherits="P1.WebForm1" %> using [Link];
<!DOCTYPE html> using [Link];
<html xmlns="[Link]
<head runat="server"> namespace P1
<title>Exposure to Web Application and {
Tool</title> public partial class WebForm1 :
</head> [Link]
<body> {
<form id="form1" runat="server"> protected void Page_Load(object
<div> sender, EventArgs e)
Enter number A:<asp:TextBox {
id="TextBox1" runat="server" />
<br /> }
Enter number B:<asp:TextBox
id="TextBox2" runat="server" /> protected void btncal_click(object
<br /> sender, EventArgs e)
Sum of A and B:<asp:TextBox {
id="TextBox3" runat="server" Enabled="false" /> int value;
<br /> value =
Convert.ToInt32([Link]) +
& Convert.ToInt32([Link]);
nbsp; &nb [Link] =
sp; [Link]();
<asp:Button ID="btncal" runat="server"
Text="SUM" OnClick="btncal_click" /> }
}
</div> } 1.2
</form>
</body>
</html> 1.1
Run time:
OUTPUT DESIGN: 1.1
1.2
Output
1.3
Program 2: Implement the HTML Controls.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="WebApplication8.WebForm1" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>HTML CONTROLS</h1>
<P>user
<input id="Text1" type="text" runat="server"/><br /></P>
<br />
<p>
password
<input id="Password1" type="password" runat="server"/></p>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="SUBMIT" OnClick="Button1_Click" />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
</form>
</body>
</html> 2.1
Implement the HTML Controls.
Design View
2.2
2.1
Output Invalid output
2.3 2.4
[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace WebApplication8
{
public partial class WebForm1 : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string uid = [Link];
String psd = [Link];
if (uid == "abc" && psd == "123")
[Link] = "log in successful";
else
[Link] = "invalid user";
}
}
} 2.2
Submit 3.3
After Reset 3.4
Design View:
PROGRAM: 3 Implement the Server Control
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="WebApplication8.WebForm2" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Name &nb
sp;
<input id="Text1" type="text" runat="server"/><br />
<br />
Course &n
bsp;
<input id="Text2" type="text" runat="server" />
<br />
<br />
Gender &n
bsp;
<input id="Radio1" type="radio" name="Gender" runat="server"/>Male
<input id="Radio2" type="radio" name="Gender" runat="server" />Female
<input id="Radio3" type="radio" name="Gender" runat="server" />Others<br />
<br /> <br />
Subject &n
bsp;
<select id="Select1" name="D1" runat="server">
<option> Maths </option>
<option> Science </option>
</select><br />
<br />
&n
bsp;
<input id="Submit1" type="submit" value="submit" runat="server" onserverclick="display" />
<input id="Submit2" type="submit" value="reset" runat="server" onserverclick="clear" />
<p id="p1" runat="server"></p>
<textarea id="t1" runat="server" />
</div> </form> </body> </html> 3.1
Design View: Output
3.1 3.2
[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace P1
{
public partial class WebForm2 : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void display(object sender, EventArgs e)
{
[Link] = "The name is " + [Link];
[Link] = "Course is " + [Link];
if ([Link] == true)
{
[Link] = "gender is Male ";
}
if ([Link] == true)
{
[Link] = "Gender is Female ";
}
if ([Link] == true)
{
[Link] = "Gender is Others";
}
[Link] = "Name is" + [Link] + "\n" + "Course is " + [Link] + "\n" +
"Subject is " + [Link];
}
protected void clear(object sender, EventArgs e)
{
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
}
}
} 3.2
Runtime
After Reset 4.4
4.2
Output After Submit
</tr>
<tr>
<td class="auto-style3">Name</td>
<td class="auto-style4">
<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Class</td>
<td>
<asp:DropDownList
ID="DropDownList1" runat="server" >
<asp:ListItem>cs</asp:ListItem>
<asp:ListItem>tamil</asp:ListItem>
<asp:ListItem>commerce</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
4.3 <td class="auto-style2">Gender</td>
<td>
<asp:RadioButton
ID="RadioButton1" runat="server" Text="Male"
Program 4: Web application using Web GroupName="a"/>
Controls
<%@ Page Language="C#" <asp:RadioButton
AutoEventWireup="true" ID="RadioButton2" runat="server"
CodeBehind="[Link]" Text="Female" GroupName="a" />
Inherits="WebApplication8.WebForm3" %> </td>
</tr>
<!DOCTYPE html> <tr>
<td class="auto-style2">email id</td>
<html <td>
xmlns="[Link] <asp:TextBox ID="TextBox3"
<head runat="server"> runat="server"></asp:TextBox>
<title></title> </td>
</head> </tr>
<body> <tr>
<form id="form1" runat="server"> <td class="auto-style2">address</td>
<table class="auto-style1"> <td>
<tr> <asp:TextBox ID="TextBox4"
<td class="auto-style2">Roll</td> runat="server"
<td> TextMode="MultiLine"></asp:TextBox>
<asp:TextBox ID="TextBox1" </td>
runat="server"></asp:TextBox> </tr>
</td> <tr> 4.2
4.1
<td class="auto-style5">Language Known</td>
<td class="auto-style6">
<asp:CheckBox ID="CheckBox1" runat="server" Text="Tamil" />
<asp:CheckBox ID="CheckBox2" runat="server" Text="English" />
<asp:CheckBox ID="CheckBox3" runat="server" Text="Hindi" />
</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit"
/>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Reset" />
4.3
<p>
Students Details</p> </p>
<p> <p </p>
<asp:Label ID="Label1" runat="server"></asp:Label> <p> </p>
<p> </p>
</p> <p> </p>
<p> <p> </p>
<asp:Label ID="Label2" runat="server"></asp:Label> <p> </p>
</p> <p> </p>
<p> </form>
<asp:Label ID="Label3" runat="server"></asp:Label> </body>
</p> </html>
<p> 4.5
<asp:Label ID="Label4" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="Label5" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="Label6" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="Label7" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="Label8" runat="server"></asp:Label>
</p>
<p>
<asp:Label ID="Label9" runat="server"></asp:Label>
</p>
<p> 4.4
5.1
[Link] 4.6 Runtime
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace WebApplication8
{
public partial class WebForm3 : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
[Link] = "Roll No :" + [Link]; 5.2
[Link] = "Name :" + [Link];
[Link] = "Class :" + [Link];
if ([Link]) Add item:
{
[Link] = "Gender is male";
}
else
[Link] = "Gender is Female";
[Link] = "Email id :" + [Link];
[Link] = "Address :" + [Link];
if ([Link])
{
[Link] = "Languages known is Tamil";
}
if ([Link])
{ [Link] = "English"; }
if ([Link])
{ [Link] = "Hindi"; }
}
5.3
}
EventArgs e)
}
}
protected void Button2_Click(object sender,
CheckBox List
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = false;
[Link] = false;
[Link] = false;
[Link] = false;
[Link] = false;
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
5.6
4.7
Remove Item: Dropdown List
5.7
5.5
5.4
Program 5: Web application using list Controls.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="WebApplication8.WebForm5" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div> List Control<br />
[Link]<br />
<asp:ListBox ID="ListBox1" runat="server" Height="128px"
Width="131px"></asp:ListBox>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="ADD" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="REMOVE" />
<br />
2. CheckBoxList
3. DropDownList<br />
<asp:Label ID="Label1" runat="server" Text="IT'sMe"></asp:Label>
&n
bsp;  
;  
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList> 5.1
<br />
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged">
<asp:ListItem>Underline</asp:ListItem>
<asp:ListItem>Bold</asp:ListItem>
<asp:ListItem>Italic</asp:ListItem>
</asp:CheckBoxList>
4. RadioButtonList<br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged1">
<asp:ListItem Value="1" Text="[Link]" />
<asp:ListItem Value="2" Text="[Link]" />
<asp:ListItem Value="3" Text="[Link]" />
</asp:RadioButtonList>
<asp:Image ID="Image1" runat="server" Height="201px" Width="202px" />
<br />
</div> </form> </body> </html> 5.2
[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace WebApplication8
{
public partial class WebForm5 : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
[Link]([Link]);
[Link] = [Link];
}
protected void Button2_Click(object sender, EventArgs e)
{
[Link]([Link]);
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
[Link] = Convert.ToInt32([Link]);
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
[Link] = false;
[Link] = false;
[Link] = false;
foreach (ListItem item in [Link])
{
5.3
if ([Link])
{
if ([Link] == "Bold")
[Link] = true;
if ([Link] == "Italic")
[Link] = true;
if ([Link] == "Underline")
[Link] = true;
}
}
}
protected void RadioButtonList1_SelectedIndexChanged1(object sender, EventArgs e)
{
string v = "Img/" + [Link];
[Link] = v;
}
}
} 5.4
6.3
6.1
6.2
[Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace Rctrl
{
public partial class WebForm2 : [Link]
{
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
[Link] = "Selected Date: " +
[Link]();
}
protected void Button1_Click(object sender, EventArgs e)
{
if ([Link] && [Link])
{
string path = "Images/" + [Link];
[Link]([Link](path));
[Link] = path;
[Link] = "Upload Successful!";
}
else
{
[Link] = "";
[Link] = "upload";
}
}
} 6.2
} 6.2
11.1 Design View: 11.2 Runtime: 11.3 Output
Program 6: Web page design using rich control. Validate user input using validation
control.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="Rctrl.WebForm2" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Rich Controls Demo</h2>
<!-- Calendar -->
Select Date:
<asp:Calendar ID="Calendar1" runat="server"
OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar>
<asp:Label ID="Label1" runat="server"></asp:Label>
<br /><br />
<!-- File Upload -->
Upload Image:
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:RequiredFieldValidator ID="rfvFile" runat="server"
ControlToValidate="FileUpload1"
ErrorMessage="Please choose a file"
ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revFile" runat="server"
ControlToValidate="FileUpload1"
ValidationExpression=".*\.(jpg|jpeg|png|gif)$"
ErrorMessage="Only image files allowed"
ForeColor="Red"></asp:RegularExpressionValidator>
<asp:Button ID="Button1" runat="server"
Text="Upload" OnClick="Button1_Click" />
<asp:Label ID="Label2" runat="server"></asp:Label>
<br /><br />
<!-- Image -->
<asp:Image ID="Image1" runat="server" Height="150px" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" />
</div>
</form> </body> </html> 6.1
Design View 10.3
Program 11: Implement the XML Classes.
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="[Link]" Inherits="WebApplication9.WebForm2" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="load" />
<br />
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace WebApplication9
{
public partial class WebForm2 : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
[Link]("<user><name>IRAM</name><role>Admin</role></user>");
string name = [Link]("//name").InnerText;
[Link] = "User Name : " + name;
}
}
}
10.2 After sqlconfiguration 10.4
10.5
<%@ Page Language="C#"
AutoEventWireup="true"
CodeBehind="[Link]"
Inherits="WebApplication9.WebForm1" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1"
runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"