0% found this document useful (0 votes)
14 views50 pages

Aspnet Practicle File

The document is a practical file for ASP.NET, detailing various web server controls, user controls, validation controls, dropdown lists, and master pages. It includes code snippets for each type of control and their corresponding HTML structure. The document serves as a guide for BCA students at Veer Narmad South Gujarat University, focusing on practical applications in ASP.NET development.

Uploaded by

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

Aspnet Practicle File

The document is a practical file for ASP.NET, detailing various web server controls, user controls, validation controls, dropdown lists, and master pages. It includes code snippets for each type of control and their corresponding HTML structure. The document serves as a guide for BCA students at Veer Narmad South Gujarat University, focusing on practical applications in ASP.NET development.

Uploaded by

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

lOMoARcPSD|32214392

Asp.net Practicle File

bca sem-5 (Veer Narmad South Gujarat University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Dhruv Sharma ([email protected])
lOMoARcPSD|32214392

1) Asp.net web server controls

 WebServerControls.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="WebServerControls.aspx.vb"
Inherits="WebServerControls" %>

<!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">
.style2 { width: 181px; height: 27px; }
.style5 { width: 348px; }
.style6 { height: 27px; width: 348px; }
.style7 { height: 33px; }
.style8 { width: 348px; height: 33px; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1px solid black" style="width: 485px">
<tr>
<td align="center" class="style1" colspan="2"> &nbsp;<br />
ASP.NET Web Server Controls<br />
</td>
</tr>
<tr>
<td class="style1">
Label :-</td>
<td class="style5">
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="style2">
TextBox :-</td>
<td class="style6">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
ImageButton :-</td>
<td class="style5">
<asp:ImageButton ID="ImageButton1" runat="server" Height="76px"
ImageUrl="~/images/image1.png" Width="91px" />
</td>
</tr>
<tr>
<td class="style1">
RadioButton :-</td>

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

<td class="style5">
<asp:RadioButton ID="RadioButton1" runat="server" Text="RadioButton1" />
&nbsp;<asp:RadioButton ID="RadioButton2" runat="server"
Text="RadioButton2" />
</td>
</tr>
<tr>
<td class="style1">
CheckBox :-</td>
<td class="style5">
<asp:CheckBox ID="CheckBox1" runat="server" Text="CheckBox1" />
&nbsp;&nbsp; <asp:CheckBox ID="CheckBox2" runat="server" Text="CheckBox2" />
</td>
</tr>
<tr>
<td class="style1">
ListBox :-</td>
<td class="style5">
<asp:ListBox ID="ListBox1" runat="server" Height="64px">
<asp:ListItem>ListItem1</asp:ListItem>
<asp:ListItem>ListItem2</asp:ListItem>
<asp:ListItem>ListItem3</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:ListBox>
</td>
</tr>
<tr>
<td class="style7">
Button :-</td>
<td class="style8">
<asp:Button ID="Button1" runat="server" Text="Button" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 Output

2) Asp.net Web User Control

 WebUserControl.ascx
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="WebUserControl.ascx.vb"
Inherits="WebUserControl" %>
<asp:Label ID="Label2" runat="server" Text="Name"></asp:Label>
&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /><br />
<asp:Button ID="btnGreet" runat="server" Text="Greet" /><br /><br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

 WebUserControl.ascx.vb
Partial Class WebUserControl
Inherits System.Web.UI.UserControl
Protected Sub btnGreet_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnGreet.Click
Label2.Text = "Welcom " + TextBox1.Text
End Sub
End Class

 Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<%@ Register TagPrefix="Greet" TagName="welcome" Src="/WebUserControl.ascx" %>
<!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 id="Head1" runat="server">
<title></title>
</head>
<body>

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

<form id="form1" runat="server">


<div>
<Greet:welcome id="welcome" runat="server" />
</div>
</form>
</body>
</html>

 Output

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

3) Asp.net validation Controls

ValidationControls.aspx
Page Language="VB" AutoEventWireup="false" CodeFile="ValidationControls.aspx.vb"
Inherits="ValidationControls" %>

<!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">
.style3 { width: 171px; }
.style4 { width: 172px; }
</style>
</head>
<body>
<form id="form1" runat="server"><div>
<table style="width:100%;">
<tr>
<td align="center" class="style1" colspan="2"><br />
ASP.NET Validation Controls</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="style4">&nbsp;</td>
<td class="style3">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="style4">User Name :-</td>
<td class="style3">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td rowspan="5">
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ForeColor="Red" Width="311px" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1" Display="None" ErrorMessage="Plz Enter User
name." ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4">Email :-</td>
<td class="style3"><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
<td>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="TextBox2" Display="None"
ErrorMessage="Plz Enter Valid Email" ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style4">Age :-</td>
<td class="style3">
<asp:TextBox ID="TextBox3" runat="server"
TextMode="Number"></asp:TextBox>
</td>
<td>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox3" Display="None" ErrorMessage="Age must between 18 to 45"
ForeColor="Red" MaximumValue="45" MinimumValue="18" Type="Integer"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="style4">Password :-</td>
<td class="style3"><asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="style4">Confirm Password :-</td>
<td class="style3"><asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
<td><asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox4" ControlToValidate="TextBox5" Display="None"
ErrorMessage="Password are missmatch" ForeColor="Red"></asp:CompareValidator></td>
</tr>
<tr>
<td class="style4">&nbsp;</td>
<td class="style3">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="style4">&nbsp;</td>
<td class="style3"><asp:Button ID="Button1" runat="server" Text="Submit" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</div></form>
</body>
</html>

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 Output

4) Drop Down List application (Country, State, City)

DropDownList.aspx
Page Language="VB" AutoEventWireup="false" CodeFile="DropDownList.aspx.vb"
Inherits="DropDownList" %>

<!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">
.style2 { width: 152px; }
.style3 { width: 97px; }
</style>
</head>

<body>
<form id="form1" runat="server">
<div>
<table style="width:100%;">

<tr>
<td align="center" class="style1" colspan="2"><br />
Drop Down List Application
</td>
<td>
&nbsp;</td>
</tr>

<tr>
<td class="style3">
&nbsp;</td>
<td class="style2">

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

&nbsp;</td>
<td>
&nbsp;</td>
</tr>

<tr>
<td class="style3">
Country :-</td>
<td class="style2">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>Ukraine</asp:ListItem>
<asp:ListItem>Russia</asp:ListItem>
</asp:DropDownList>
</td>
<td>&nbsp;</td>
</tr>

<tr>
<td class="style3">
State :-</td>
<td class="style2">
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>
Gujarat
</asp:ListItem>
<asp:ListItem>
Haryana
</asp:ListItem>
<asp:ListItem>
Andhra Pradesh
</asp:ListItem>
</asp:DropDownList>
</td>
<td>&nbsp;</td>
</tr>

<tr>
<td class="style3">
City :-</td>
<td class="style2">
<asp:DropDownList ID="DropDownList3" runat="server">
<asp:ListItem>
Surat
</asp:ListItem>
<asp:ListItem>
Valsad
</asp:ListItem>
<asp:ListItem>
Godhra
</asp:ListItem>
</asp:DropDownList>
</td>
<td>&nbsp;</td>

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

</tr>

</table>

</div>
</form>
</body>
</html>

 Output

5) Write a practical of Master Page.

MasterPage.master
Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

<!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>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1 { width: 45px; font-size: small; }
.style2 { font-size: large; }
.style3 { font-size: xx-large; height: 23px; }
.style4 { width: 45px; font-size: small; text-decoration: underline; }
.style5 { width: 45px; font-size: small; height: 23px; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 66%;" border="1px">
<tr><td class="style5">
<asp:Image ID="Image1" runat="server" Height="93px"
ImageUrl="~/images/nobita.png" Width="105px" /></td>
<td align="center" class="style3"> Master Page</td>
</tr>
<tr><td class="style4" align="center">
<strong>Menu</strong><br />
<a href="Page1.aspx">Page1</a><br />
<a href="Page2.aspx">Page2</a><br />

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

</td>
<td>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr><td class="style1"> &nbsp;</td>
<td class="style2"> Footer</td>
</tr>
</table>
</div>
</form>
</body>
</html>

 Page1.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="Page1.aspx.vb" Inherits="Page1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width:100%;">
<tr><td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
<tr><td> &nbsp;</td>
<td align="center"> Page 1</td>
<td> &nbsp;</td>
</tr>
<tr><td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
</table>
</asp:Content>

 Page2.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="Page2.aspx.vb" Inherits="Page2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width: 100%;">
<tr><td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
<tr><td> &nbsp;</td>
<td align="center"> Page 2</td>
<td> &nbsp;</td>
</tr>
<tr><td> &nbsp;</td>
<td> &nbsp;</td>

10

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

<td> &nbsp;</td>
</tr>
</table>
</asp:Content>

 Output

11

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

6) Write a Practical of Themes (Skin File, CSS)

 StyleSheet.css body { background-color: Aqua; font-family: Verdana;


font-size: large; } p { background-color: Red; }

 SkinFile.skin
<asp:Button runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="Red" Text="Button" />
<asp:Label SkinId="Label1" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="#0066FF" Text="Label"></asp:Label>
<asp:Label SkinId="Label2" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="#669900" Text="Label"></asp:Label>

 Theme.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Theme.aspx.vb"
Inherits="Styles_Theme" %>
<!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 id="Head1" runat="server">
<title></title><link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server"><div><center><p>SkinFile and CSS</p>
<asp:Label ID="lbl1" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="#0066FF" Text="Label"></asp:Label>
<asp:Label ID="lbl2" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="#669900" Text="Label"></asp:Label>
<asp:Label ID="Label3" runat="server" SkinID="Label1" Text="Label"></asp:Label>
<asp:Label ID="lbl4" runat="server" SkinID="Label2" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="Red" Text="btn1" />
<asp:Button ID="Button2" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="Red" Text="btn2" />
<asp:Button ID="Button3" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="Red" Text="btn3" />
<asp:Button ID="Button4" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="Red" Text="btn4" />
<asp:Button ID="Button5" runat="server" Font-Bold="True" Font-Italic="True"
ForeColor="Red" Text="btn5" />
</center></div></form>
</body>
</html>

 Output

12

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

7) Write a Practical of Repeater Control.

 RepeaterControl.aspx
<!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">
Repeater Control<br /><br />
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="AccessDataSource1">
<ItemTemplate>
(<%# Eval("No")%>) &nbsp <%# Eval("Q")%> &nbsp :- &nbsp <%# Eval("A")%><br />
</ItemTemplate>
</asp:Repeater>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/RepeaterDB.accdb"
SelectCommand="SELECT * FROM [FullForms]"></asp:AccessDataSource>
</form>
</body>
</html>

 Output

8) Write a Practical of Site map Path Control.

 MasterPage.master
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<!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">

13

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

<head id="Head1" runat="server">


<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1 { width: 45px; font-size: small; }
.style2 { font-size: large; }
.style3 { font-size: xx-large; height: 23px; }
.style4 { width: 45px; font-size: small; text-decoration: underline; }
.style5 { width: 45px; font-size: small; height: 23px; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 66%;" border="1px">
<tr>
<td class="style5">
<asp:Image ID="Image1" runat="server" Height="93px"
ImageUrl="~/images/nobita.png" Width="105px" />
</td>
<td align="center" class="style3">Site Map Path Control</td>
</tr>
<tr>
<td class="style4" align="center" rowspan="3">
<asp:Menu ID="Menu1" runat="server"
DataSourceID="SiteMapDataSource1">
</asp:Menu>
</td>
<td>
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td class="style2"> Footer</td>
</tr>
</table>
</div>
</form>
</body>
</html>

 Page1.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="Page1.aspx.vb" Inherits="Page1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

14

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width:100%;">
<tr>
<td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
<tr>
<td> &nbsp;</td>
<td align="center"> Page 1</td>
<td> &nbsp;</td>
</tr>
<tr>
<td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
</table>
</asp:Content>

 Page2.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="Page2.aspx.vb" Inherits="Page2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width: 100%;">
<tr>
<td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
<tr>
<td> &nbsp;</td>
<td align="center"> Page 2</td>
<td> &nbsp;</td>
</tr>
<tr>
<td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
</table>
</asp:Content>

 Page2_1.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="Page2_1.aspx.vb" Inherits="Page2_1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width: 100%;">

15

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

<tr>
<td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
<tr>
<td> &nbsp;</td>
<td align="center"> Page 2.1</td>
<td> &nbsp;</td>
</tr>
<tr>
<td> &nbsp;</td>
<td> &nbsp;</td>
<td> &nbsp;</td>
</tr>
</table>
</asp:Content>

 Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Page1.aspx" title="Page1" description="Page1">
<siteMapNode url="Page2.aspx" title="Page2" description="Page2">
<siteMapNode url="Page2_1.aspx" title="Page2.1" description="Page2.1" />
</siteMapNode>
</siteMapNode>
</siteMap>

 Output

9) Develop a Asp.net application for state management through login, home, logout
pages. Use cookies and session object to manage session.

 login.aspx
<% @ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb"
%> Inherits="login"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

16

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1 { width: 500px; }
.style2 { width: 142px; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1" align="center">
<tr>
<td class="style2"> &nbsp;</td>
<td>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-
Size="20pt"
Text="Login"></asp:Label>
</td>
</tr>
<tr>
<td class="style2">
Name</td>
<td>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
Email</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
Password</td>
<td>
<asp:TextBox ID="txtPass" runat="server"
TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2"> &nbsp;</td>
<td>
<asp:Button ID="btnLogin" runat="server" Text="Login" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

17

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 home.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="home.aspx.vb" Inherits="home" %>


<!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 { width: 500px; }
.style2 { height: 23px; }
.style3 { width: 187px; }
.style4 { height: 23px; width: 187px; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1" align="center" border="5" cellspacing="0">
<tr>
<td class="style3">
Name</td>
<td>
<asp:Label ID="lblName" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="style4">
Email</td>
<td class="style2">
<asp:Label ID="lblEmail" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td class="style3"> &nbsp;</td>
<td> &nbsp;</td>
</tr>
<tr>
<td class="style3"> &nbsp;</td>
<td>
<asp:Button ID="btnLogout" runat="server" Text="Logout" />
</td>
</tr>
<tr>
<td class="style4">
</td>
<td class="style2">
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

18

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 login.aspx.vb
Imports System.Data.OleDb
Imports System.Data
Imports System.Web.Configuration

Partial Class login


Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnLogin.Click
Try
Dim cmd As New OleDbCommand("SELECT [Name],[Email],[Password] FROM [user]
WHERE [Name]='" + txtName.Text + "' and [Email]='" + txtEmail.Text + "' and [Password]='"
+ txtPass.Text + "'", con)
Dim read As OleDbDataReader
con.Open()
read = cmd.ExecuteReader
If read.Read() Then
MsgBox("Login")
Dim c As New HttpCookie("Detail")
c.Values.Add("name", txtName.Text)
Response.Cookies.Add(c)
Session("email") = txtEmail.Text
Response.Redirect("home.aspx")
Else
MsgBox("Login Failed")
End If con.Close()
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

 home.aspx.vb
Partial Class home
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
lblEmail.Text = Session("email")
Dim rc As HttpCookie = Request.Cookies("detail")
lblName.Text = rc.Values("name").ToString
End Sub
Protected Sub btnLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnLogout.Click

Response.Cookies("detail").Expires = Now
Session.Clear()
Response.Redirect("login.aspx")
End Sub

19

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

End Class

 Output

10) Design a Website in Asp.net for selling and purchasing items like OLX.com, in which
Seller can manage items.
Purchaser can view and purchase the items.

20

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 OLXMasterPage.master

 Admin.aspx

 Admin.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class Admin
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Sub displayRecord()
Dim cmd As New OleDbCommand("SELECT * FROM ItemMast", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
gdvAdmin.DataSourcelD = ""
gdvAdmin.DataSource = ds
Me.DataBind()

21

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

End Sub
Sub databindwithlist()
Dim cmd As New OleDbCommand("select * from ItemCatMast", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
IsbCname.DataSource = ds
IsbCname.DataValueField = "ICCode"
IsbCname.DataTextField = "ICName"
IsoCname.DataBind()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load()
If (IsPostBack = False) Then
databindwithlist() End If
displayRecord() End Sub
Sub clearcontrol()
txtCode.Text = ""
txtName.Text = ""
IsbCname.ClearSelection()
txtQty.Text = ""
txtPrice.Text = ""
calPur.SelectedDate = Now

End Sub
Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles
btninsert.Click()
Try
Dim cmd As New OleDbCommand("INSERT INTO ItemMast
values(@id,@nm,@ic,@qt,@pr,@pd)", con)
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtCode.Text
cmd.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text
cmd.Parameters.Add("@ic", OleDbType.Numeric).Value = IsbCname.SelectedValue
cmd.Parameters.Add("@qt", OleDbType.Numeric).Value = txtQty.Text
cmd.Parameters.Add("@pr", OleDbType.Numeric).Value = txtPrice.Text
cmd.Parameters.Add("@pd", OleDbType.Date).Value = calPur.SelectedDate
con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Item Added")
clearcontrol()
displayRecord()
Else
MsgBox("Something went wrong")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try

22

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

End Sub
Protected Sub gdvAdmin_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles gdvAdmin.SelectedIndexChanged txtCode.Text =
gdvAdmin.SelectedRow.Cells(1).Text txtName.Text =
gdvAdmin.SelectedRow.Cells(2).Text
IsbCname.SelectedValue = gdvAdmin.SelectedRow.Cells(3).Text
txtQty.Text = gdvAdmin.SelectedRow.Cells(4).Text txtPrice.Text
= gdvAdmin.SelectedRow.Cells(5).Text calPur.SelectedDate =
gdvAdmin.SelectedRow.Cells(6).Text
End Sub
Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnDelete.Click txtCode.ReadOnly = True
Try
Dim cmd As New OleDbCommand("DELETE FROM ItemMast WHERE ItemCode=@id", con)
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtCode.Text con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Item Deleted")
clearcontrol()
displayRecord()
txtCode.ReadOnly = False
Else
MsgBox("Something went wrong")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles
btnUpdate.Click()
txtCode.ReadOnly = True
Try
Dim cmd As New OleDbCommand("UPDATE [ItemMast] SET
[ItemName]=@nm,[ICCode]=@ic,[Qty]=@at,[Price]=@pr,[PDate]=@pd WHERE [ItemCode]=@id", con)
cmd.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text
cmd.Parameters.Add("@ic", OleDbType.Numeric).Value = IsbCname.SelectedValue
cmd.Parameters.Add("@qt", OleDbType.Numeric).Value = txtQty.Text
cmd.Parameters.Add("@pr", OleDbType.Numeric).Value = txtPrice.Text
cmd.Parameters.Add("@pd", OleDbType.Date).Value = calPur.SelectedDate
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtCode.Text con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Item Updated")
clearcontrol()
displayRecord()
txtCode.ReadOnly = False

23

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Else
MsgBox("Something went wrong")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

 Purchaser.aspx

 Purchaser.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class Purchaser
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Sub displayRecord()
Dim cmd As New OleDbCommand("SELECT * FROM ItemMast", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
gdvPurchase.DataSourcelD = ""
gdvPurchase.DataSource = ds
Me.DataBind()
End Sub
Protected Sub gdvPurchase_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles gdvPurchase.SelectedIndexChanged

24

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

calPar.SelectedDate = gdvPurchase.SelectedRow.Cells(6).Text txtid.Text =


gdvPurchase.SelectedRow.Cells(1).Text
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load() displayRecord()
End Sub
Protected Sub btnPurchase_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnPurchase.Click
Try
Dim cmd As New OleDbCommand("UPDATE [ItemMast] SET [PDate]=@pd WHERE
[ItemCode]=@id", con)
cmd.Parameters.Add("@pd", OleDbType.Date).Value = calPar.SelectedDate
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtid.Text con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Item Purchase Successfully")
displayRecord()
Else
MsgBox("Something went wrong")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

 Output

25

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

11) Design a module using Asp.net for online book shopping. Use proper validations.
Admin can manage the book details and stock.
User can view the different category of books and place an order for books.

26

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 BookShoppingMasterPage.master

 Web.sitemap

<?xml version="1.0" encoding="utf-8" ?>


<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="index.aspx" title="Home" description="Home">
<siteMapNode url="Admin.aspx" title="Admin" description="Admin" />
<siteMapNode url="user.aspx" title="User" description="User" />
</siteMapNode>
</siteMap>

 Index.aspx

 Index.aspx.vb
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class index

27

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
Dim cmd As New OleDbCommand("select * from BookCatMast", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
gridHome.DataSourcelD = ""
gridHome.DataSource = ds
Me.DataBind()
End Sub
End Class

 Admin.aspx

 Admin.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class Admin
Inherits System.Web.UI.Page
Dim con As
NewOleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Sub clearcontron() txtld.Text = "" txtName.Text = ""
Isbcode.ClearSelection() txtqty.Text = "" txtPrice.Text = ""
End Sub

28

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles btnInsert.Click
If Page.IsValid Then
Try
Dim cmd As New OleDbCommand("Insert into BookMast values(@id,@nm,@code,@qt,@pr)", con)
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = Val(txtld.Text)
cmd.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text
cmd.Parameters.Add("@code", OleDbType.Numeric).Value = Isbcode.SelectedValue
cmd.Parameters.Add("@qt", OleDbType.Numeric).Value = Val(txtqty.Text)
cmd.Parameters.Add("@pr", OleDbType.Numeric).Value = Val(txtPrice.Text)
con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Book Added")
clearcontron()
gdvAdmin.DataBind()
Else
MsgBox("Something went wrong..")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End If
End Sub
Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnDelete.Click
If Page.IsValid Then
Try
Dim cmd As New OleDbCommand("delete from BookMast where BookCode=@id",
con)
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtld.Text
con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Book Deleted")
clearcontron() txtld.ReadOnly
= False
Else
MsgBox("Something went wrong..")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try

29

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

End If
End Sub
Sub databindwithlist()
Dim cmd As New OleDbCommand("select * from BookCatMast", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
Isbcode.DataSource = ds
Isbcode.DataTextField = "BootCatName"
Isbcode.DataValueField = "BookCatCode"
Isbcode.DataBind()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load()
If IsPostBack = False Then
databindwithlist()
End If
Dim cmd As New OleDbCommand("select * from BookMast", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
gdvAdmin.DataSourcelD = ""
gdvAdmin.DataSource = ds
Me.DataBind()
End Sub
Protected Sub gdvAdmin_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles gdvAdmin.SelectedIndexChanged
txtld.ReadOnly = True
txtId.Text = gdvAdmin.SelectedRow.Cells(1).Text
txtName.Text = gdvAdmin.SelectedRow.Cells(2).Text
Isbcode.SelectedValue = gdvAdmin.SelectedRow.Cells(3).Text
txtqty.Text = gdvAdmin.SelectedRow.Cells(4).Text
txtPrice.Text = gdvAdmin.SelectedRow.Cells(5).Text
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnUpdate.Click
If Page.IsValid Then
Try
Dim cmd As New OleDbCommand("update BookMast set [BookName]=@nm,
[BookCatCode]=@code,[Qty]=@ qt,[Price]=@pr where [BookCode]=@id", con)
cmd.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text
cmd.Parameters.Add("@code", OleDbType.Numeric).Value = Isbcode.SelectedValue
cmd.Parameters.Add("@qt", OleDbType.Numeric).Value = Val(txtqty.Text)
cmd.Parameters.Add("@pr", OleDbType.Numeric).Value = Val(txtPrice.Text)
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = Val(txtid.Text)
con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Book Updated ")
clearcontron()
Else
MsgBox("Something went wrong..")
End If

30

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End If
End Sub
End Class

 user.aspx

 user.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class user
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Sub displayrecord()
Dim cmd As New OleDbCommand("select * from BookTrans", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds) gdvUser.DataSourcelD
= "" gdvUser.DataSource = ds
End Sub
Sub databindwithlist()
Dim cmd As New OleDbCommand("select BookCode,BookName from BookMast", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds) Isbcode.DataSource =
ds
Isbcode.DataTextField = "BookName"
Isbcode.DataValueField = "BookCode"

31

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Isbcode.DataBind()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If IsPostBack = False Then
databindwithlist() End If
displayrecord() End Sub
Sub clearControl()
txtid.Text = ""
Isbcode.ClearSelection()
txtqty.Text = ""
End Sub
Protected Sub btnPurchase_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnPurchase.Click
Try
Dim cmd As New OleDbCommand("Insert into BookTrans values(@id,@code,@qty)", con)
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtid.Text 'Dim a As
Integer = Int32.Parse(Isbcode.SelectedValue)
cmd.Parameters.Add("@code", OleDbType.Decimal).Value = Isbcode.SelectedValue
cmd.Parameters.Add("@qty", OleDbType.Numeric).Value = txtqty.Text
Dim flag As Integer = 0
con.Open()
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Book Ordered Successfully")
clearControl() displayrecord()
Else
MsgBox("Something went wrong")
End If
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

 Output

32

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

12) Develop a Website for movie ticket booking.

33

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Provide facility to user like login, registration.


Provide facility for view tickets and booking.

 MovieMasterPage.master

 Register.aspx

 Register.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class Register
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Sub clearcontrol() txtld.Text = "" txtPass.Text = ""
txtName.Text = "" txtAddress.Text = "" txtPhone.Text = ""
txtEmail.Text = ""
rdbMale.Checked = False
rdbFemale.Checked = False
End Sub

34

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Protected Sub btnRegister_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles
btnRegister.Click()
Try
Dim cmd As New OleDbCommand("INSERT INTO UserMast
VALUES(@id,@ps,@nm,@add,@ph,@em,@gen)", con)
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtld.Text
cmd.Parameters.Add("@ps", OleDbType.VarChar).Value = txtPass.Text
cmd.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text
cmd.Parameters.Add("@add", OleDbType.VarChar).Value = txtAddress.Text
cmd.Parameters.Add("@ph", OleDbType.VarChar).Value = txtPhone.Text
cmd.Parameters.Add("@em", OleDbType.VarChar).Value = txtEmail.Text
Dim gen As String = ""
If rdbMale.Checked Then
gen = "Male" Else
gen = "Female"
End If
cmd.Parameters.Add("@gen", OleDbType.VarChar).Value = gen
con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Register Successfull")
clearcontrol()

Response.Redirect("Login.aspx")
Else
MsgBox("Something went wrong")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

 Login.aspx

35

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 Login.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class Login
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles
btnLogin.Click()
Try
Dim cmd As New OleDbCommand("Select count(*) from UserMast where [UserlD]=@id
and [Email]=@el and [Password]=@ps", con)
cmd.Parameters.Add("@id", OleDbType.VarChar).Value = txtID.Text
cmd.Parameters.Add("@el", OleDbType.VarChar).Value = txtEmail.Text
cmd.Parameters.Add("@ps", OleDbType.VarChar).Value = txtPass.Text
Dim flag As Integer = 0
con.Open()
flag = cmd.ExecuteScalar
con.Close() If flag = 1
Then
Session("id") = txtID.Text
MsgBox("Login Successfull")
Response.Redirect("Home.aspx")
Else
MsgBox("Login Failed")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

36

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 Home.aspx

 Home.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class Home
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
Dim cmd As New OleDbCommand("select * from MticketMast", con)

Dim da As New OleDbDataAdapter(cmd)


Dim ds As New DataSet
da.Fill(ds)
gdvmovie.DataSourcelD = ""
gdvmovie.DataSource = ds
Me.DataBind()
End Sub
Protected Sub gdvmovie_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles gdvmovie.SelectedIndexChanged txtmid.Text =
gdvmovie.SelectedRow.Cells(1).Text
Dim nm As Integer = Session("id")
txtuid.Text = nm
End Sub
Protected Sub btnBook_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnBook.Click
Try
Dim cmd As New OleDbCommand("Insert Into Booking(MID,Qty,UserID)
values(@mid,@qt,@uid)", con)

37

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

cmd.Parameters.Add("@mid", OleDbType.Numeric).Value = txtmid.Text


cmd.Parameters.Add("@qt", OleDbType.Numeric).Value = txtqty.Text
cmd.Parameters.Add("@uid", OleDbType.Numeric).Value = txtuid.Text Dim
flag As Integer = 0
con.Open()
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Booked Ticket Successfully")
txtmid.Text = "" txtqty.Text = ""
txtuid.Text = ""
Else
MsgBox("Something Went Wong..")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
Protected Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnShow.Click
Response.Redirect("bookingupdate.aspx")
End Sub
End Class

 Bookingupdate.aspx

 Bookingupdate.aspx.vb

Imports System.Data
Imports System.Data.OleDb

38

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Imports System.Web.Configuration
Partial Class bookingupdate
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Sub databindwithlistbox()
Dim cmd As New OleDbCommand("select [MID],[MovieName] from [MticketMast]", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
IstMname.DataSource = ds
IstMname.DataTextField = "MovieName"
IstMname.DataValueField = "MID"
IstWname.DataBind()

End Sub
Sub displayrecord()
Dim cmd As New OleDbCommand("select * from [Booking] where UserlD=" +
Session("id"),
con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds) gdvbook.DataSourcelD
= "" gdvbook.DataSource = ds
Me.DataBind()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If IsPostBack = False Then
databindwithlistbox() End
If displayrecord()
End Sub
Protected Sub gdvbook_SelectedindexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles gdvbook.SelectedIndexChanged
IstWiname.SelectedValue = gdvbook.SelectedRow.Cells(2).Text
txtqty.Text = gdvbook.SelectedRow.Cells(3).Text
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnUpdate.Click
Try
Dim cmd As New OleDbCommand("UPDATE Booking SET [MID]=@nm, [Qty]=@qt where
[UserlD]=@uid", con)
cmd.Parameters.Add("@nm", OleDbType.Numeric).Value = IstMname.SelectedValue
cmd.Parameters.Add("@qt", OleDbType.Numeric).Value = txtqty.Text
cmd.Parameters.Add("@uid", OleDbType.Numeric).Value = Session("id")
con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close() If flag > O Then
MsgBox("Booking Updated")
txtqty.Text = ""
IstMname.ClearSelection()
displayrecord()
Else
MsgBox("Something went wrong..")

39

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

 UpdateProfile.aspx

 UpdateProfile.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class UpdateProfile
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
Dim cmd As New OleDbCommand("select *from UserMast where UserlD=" +
Session("id"), con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds) gdvuser.DataSourcelD
= "" gdvuser.DataSource = ds

40

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Me.DataBind()
End Sub
Sub clearcontrol()
txtld.Text = ""
txtPass.Text = ""
txtName.Text = ""
txtAddress.Text = ""
txtPhone.Text = ""
txtEmail.Text = ""
rdbMale.Checked = False
rdbFemale.Checked = False
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnUpdate.Click
Try
Dim cmd As New OleDbCommand("UPDATE UserMast SET [Password]=@ps,[Name]=@nm,
[Address]=@add, [Phone]=@ph,[Email]=@em,[Gender]=@gen where [UserlD]=@id", con)
cmd.Parameters.Add("@ps", OleDbType.VarChar).Value = txtPass.Text
cmd.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text
cmd.Parameters.Add("@add", OleDbType.VarChar).Value = txtAddress.Text
cmd.Parameters.Add("@ph", OleDbType.VarChar).Value = txtPhone.Text
cmd.Parameters.Add("@em", OleDbType.VarChar).Value = txtEmail.Text
Dim gen As String = ""
If rdbMale.Checked Then
gen = "Male" End If
cmd.Parameters.Add("@gen", OleDbType.VarChar).Value = gen
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtld.Text con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close()
If flag > O Then
MsgBox("Update Successfull")
clearcontrol()
Response.Redirect("Home.aspx")
Else
MsgBox("Something went wrong")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
Protected Sub gdvuser_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles gdvuser.SelectedIndexChanged txtld.Text =
gdvuser.SelectedRow.Cells(1).Text txtPass.Text =
gdvuser.SelectedRow.Cells(2).Text txtName.Text =
gdvuser.SelectedRow.Cells(3).Text txtAddress.Text =
gdvuser.SelectedRow.Cells(4).Text txtPhone.Text =
gdvuser.SelectedRow.Cells(5).Text txtEmail.Text =
gdvuser.SelectedRow.Cells(6).Text Dim gen As String =
gdvuser.SelectedRow.Cells(7).Text If gen = "Male" Then
rdbMale.Checked = True Else

41

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

rdbFemale.Checked = True
End If
End Sub
End Class

 Output

42

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

13) Design a module using Asp.net for a courier service.

43

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

Admin can manage courier details and delivery details (If courier is delivered).
User can perform login and inquire status of his/her courier based on order number.

 CourierMasterPage.master

 Login.aspx

 Login.aspx.vb

Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class Login
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnLogin.Click
Try
Dim cmd As New OleDbCommand("select count(*) from UserMast where Email=@em
and Password=@pwad", con)

44

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

cmd.Parameters.Add("@em", OleDbType.VarChar).Value = txtEmail.Text


cmd.Parameters.Add("@pwd", OleDbType.VarChar).Value = txtPass.Text
con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteScalar()
con.Close()
If flag = 1 Then
MsgBox("Login Sucessfull")
txtEmail.Text = "" txtPass.Text
= ""
Response.Redirect("Courirer.aspx")
Else
MsgBox("Login Failed")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

 Courirer.aspx

45

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 Courirer.aspx.vb
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.Configuration
Partial Class Courirer
Inherits System.Web.UI.Page
Dim con As New
OleDbConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Sub ClearControl()
txtid.Text = txtName.Text = txtroute.Text = ""
calDisdate.SelectedDate = calDeldate.SelectedDate = Now
IstStatus.ClearSelection()
End Sub
Sub DisplayRecord()
Dim cmd As New OleDbCommand("Select * from CourierMast", con)
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
gdvCourier.DataSourcelD = ""
gdvCourier.DataSource = ds
Me.DataBind()
End Sub
Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnInsert.Click
Try
Dim cmd As New OleDbCommand("Insert into CourierMastvalues(@id,@nm,
@dip,@del, @rt,@st)", con)
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtid.Text
cmd.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text
cmd.Parameters.Add("@dip", OleDbType.Date).Value = calDisdate.SelectedDate
cmd.Parameters.Add("@del", OleDbType.Date).Value = calDisdate.SelectedDate
cmd.Parameters.Add("@rt", OleDbType.VarChar).Value = txtroute.Text
cmd.Parameters.Add("@st", OleDbType.VarChar).Value = IstStatus.SelectedValue
con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
If flag > O Then
MsgBox("Courier Booked")
DisplayRecord()
ClearControl()
Else
MsgBox("Something went wrong")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load() DisplayRecord()

46

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

End Sub
Protected Sub gdvCourier_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles gdvCourier.SelectedindexChanged txtid.Text =
gdvCourier.SelectedRow.Cells(1).Text
txtName.Text = gdvCourier.SelectedRow.Cells(2).Text
calDisdate.SelectedDate = gdvCourier.SelectedRow.Cells(3).Text
calDeldate.SelectedDate = gdvCourier.SelectedRow.Cells(4).Text
txtroute.Text = gdvCourier.SelectedRow.Cells(5).Text
IstStatus.SelectedValue = gdvCourier.SelectedRow.Cells(6).Text
End Sub
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnUpdate.Click
Try
Dim cmd As New OleDbCommand("UPDATE [CourierMast] SET [DeliveryName]=@nm,
[DispatchDate]=@dip, [DeliveryDate]=@del,[Route]=@rt,[Status]=@st WHERE [COID]=@id ",
con)
cmd.Parameters.Add("@nm", OleDbType.VarChar).Value = txtName.Text
cmd.Parameters.Add("@dip", OleDbType.Date).Value = calDisdate.SelectedDate
cmd.Parameters.Add("@del", OleDbType.Date).Value = calDisdate.SelectedDate
cmd.Parameters.Add(" @rt", OleDbType.VarChar).Value = txtroute.Text
cmd.Parameters.Add("@st", OleDbType.VarChar).Value = IstStatus.SelectedValue
cmd.Parameters.Add("@id", OleDbType.Numeric).Value = txtid.Text con.Open()
Dim flag As Integer = 0
flag = cmd.ExecuteNonQuery()
con.Close() If flag > O Then
MsgBox("Courier Updated")
DisplayRecord()
ClearControl()
Else
MsgBox("Something went wrong")
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Sub
End Class

47

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

 Output

48

Downloaded by Dhruv Sharma ([email protected])


lOMoARcPSD|32214392

49

Downloaded by Dhruv Sharma ([email protected])

You might also like