ASP Sheet

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

TMTBCA COLLEGE

Roll No : 64
TYBCA Sem- 5 Div- B
Name : Rawal Prerana Maheshkumar

Application : 1
Create an application to add controls (HTML (p1..aspx) as well as Web (p2.aspx) Server
Controls) dynamically at runtime on the page.

Solution :
[htmlcontrolsdynamicex.aspx] – Code View

Partial Class htmlcontrolsdynamicex


Inherits System.Web.UI.Page

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


Me.Load
Dim text As New HtmlInputText
If Not IsPostBack Then
text.ID = "txt"
text.Value = "enter your full name"
text.Style.Add("color", "red")
text.Style("background-color") = "yellow"
text.Style("font-size") = "50px"
text.Attributes("onClick") = "alert(txt.value)"
Page.Controls.Add(text)
End If
End Sub
End Class

[servercontroldynamicex.aspx] – Code View

Partial Class servercontroldynamicex


Inherits System.Web.UI.Page

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


Handles Button1.Click
Dim lbl As New Label
lbl.Style("color") = "maroon"
lbl.Style.Add("background-color", "pink")
lbl.BorderStyle = BorderStyle.Dotted
lbl.BorderColor = Drawing.Color.BlueViolet

ASP.NET Page 1
TMTBCA COLLEGE
lbl.Text = "label"
lbl.Style("font-size") = "35px"
lbl.Visible = True
PlaceHolder1.Controls.Add(lbl)
End Sub
End Class

Roll No : 64
TYBCA Sem- 5 Div- B
Name : Rawal Prerana Maheshkumar

Application : 2
Create an application to demonstrate cookies client side state management technique.

Solution :

[createCookie.aspx] – Code View

Partial Class createCookie


Inherits System.Web.UI.Page

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


Handles btncreate.Click
Dim c As New HttpCookie("color")
c.Values.Add("FC", txtfc.Text)

ASP.NET Page 2
TMTBCA COLLEGE
c.Values.Add("BG", txtbg.Text)
Response.Cookies.Add(c)
Response.Redirect("retriveCookie.aspx")
End Sub
End Class

[retriveCookie.aspx] - Code View

Imports System.Drawing
Partial Class retriveCookie
Inherits System.Web.UI.Page

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


Me.Load
Dim c As HttpCookie = Request.Cookies("color")
Dim f, b As New Color
f = Color.FromName(c.Values("FC").ToString)
b = Color.FromName(c.Values("BG").ToString)
lblretrive.ForeColor = f
lblretrive.ForeColor = b
End Sub
End Class

Roll No : 64
TYBCA Sem- 5 Div- B

ASP.NET Page 3
TMTBCA COLLEGE
Name : Rawal Prerana Maheshkumar

Application : 3
Create an application to demonstrate Query String with multiple value and URL encoding.

Solution :
[p1.aspx] - Code View

Partial Class p1
Inherits System.Web.UI.Page

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


btnqr.Click
Response.Redirect("p2.aspx?no=" + txtno.Text + "&name=" + txtname.Text)
End Sub

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


Handles btnencode.Click
Response.Redirect("p3.aspx?no=" + txtno.Text + "&name=" +
Server.UrlEncode(txtname.Text))
End Sub

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


Handles btnreset.Click
txtno.Text = ""
txtname.Text = ""
End Sub
End Class

[p2.aspx] - Code View

Partial Class p2
Inherits System.Web.UI.Page

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


Me.Load
If Request.QueryString("no") = Nothing And Request.QueryString("name") = Nothing Then
Response.Write("Number And Name not mentioned")
Else
lblno.Text = Request.QueryString("no")
lblname.Text = Request.QueryString("name")

ASP.NET Page 4
TMTBCA COLLEGE
End If
End Sub
End Class

[p3.aspx] - Code View

Partial Class p3
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
lblno.Text = Server.UrlDecode(Request.QueryString("no"))
lblname.Text = Server.UrlDecode(Request.QueryString("name"))
End Sub
End Class

Roll No : 64
TYBCA Sem- 5 Div- B
Name : Rawal Prerana Maheshkumar

Application : 4
Create an application to maintain product details using single page. (use database)
Take product no., Name, description and price as an input from the user. Display details of
the product whose product no. is given by the user.

Solution :
[web.conig]

ASP.NET Page 5
TMTBCA COLLEGE

<connectionStrings>
<add name ="con" connectionString ="Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\asp.net websites\Product
Website\App_Data\Productdb.mdf;Integrated Security=True;User Instance=True"
providerName ="System.SqlClient"/>
</connectionStrings>

[products.aspx] – Source View

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="products.aspx.vb"


Inherits="products" %>

<!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: 100%;
border: 4px solid #800000;
}
.style2
{
height: 72px;
text-decoration: underline;
}
.style4
{
width: 296px;
height: 45px;
}
.style5
{
height: 45px;
}
.style6
{
height: 43px;
}

ASP.NET Page 6
TMTBCA COLLEGE
.style7
{
height: 43px;
}
.style12
{
height: 52px;
}
.style14
{
width: 296px;
height: 46px;
}
.style15
{
height: 46px;
}
.style17
{
height: 43px;
width: 372px;
}
.style18
{
height: 46px;
width: 372px;
}
.style19
{
height: 45px;
width: 372px;
}
.style20
{
height: 53px;
text-decoration: underline;
}
.style21
{
height: 53px;
}
.style23
{

ASP.NET Page 7
TMTBCA COLLEGE
height: 47px;
}
.style24
{
height: 58px;
text-decoration: underline;
}
.style26
{
height: 257px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
<table class="style1">
<tr>
<td align="center" class="style2" colspan="3"
style="font-size: 30pt; font-weight: bolder; font-style: italic; color: #800000; background-
color: #FFFF66">
Product Details
</td>
</tr>
<tr>
<td class="style4"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
Enter Product Number</td>
<td class="style19"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
<asp:TextBox ID="txtpno" runat="server" Height="40px" Width="336px"
Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
<td class="style5">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtpno" ErrorMessage="Product no is an Mandatory Field."
Font-Bold="True" Font-Size="20pt" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>

ASP.NET Page 8
TMTBCA COLLEGE
<td class="style6"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
Enter Product Name</td>
<td class="style17"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
<asp:TextBox ID="txtpname" runat="server" Height="38px" Width="337px"
Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
<td class="style7">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtpname" ErrorMessage="Please Enter Product Name"
Font-Bold="True" Font-Size="20pt" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
Enter Description</td>
<td class="style19"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
<asp:TextBox ID="txtdes" runat="server" Height="39px" TextMode="MultiLine"
Width="339px" Font-Size="25px"></asp:TextBox>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style14"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
Enter Price</td>
<td class="style18"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
<asp:TextBox ID="txtprice" runat="server" Height="39px" Width="336px"
Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
<td class="style15">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtprice" ErrorMessage="Please Enter Price of Product."
Font-Bold="True" Font-Size="20pt" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>

ASP.NET Page 9
TMTBCA COLLEGE
<tr>
<td class="style6" colspan="3"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnins" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="37px" Text="Insert" Width="92px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnupd" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="32px" Text="Update" Width="96px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btndel" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="35px" Text="Delete" Width="91px" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btndis" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="33px" Text="Display"
Width="100px" CausesValidation="False" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnrep" runat="server" Height="33px" Text="Report"
Width="95px" CausesValidation="False" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" />
</td>
</tr>
<tr>
<td class="style12" colspan="3"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red" />
</td>
</tr>
</table>
</asp:View>
<asp:View ID="View2" runat="server">
<table class="style1">
<tr>
<td align="center" class="style20"
style="font-size: 30pt; font-weight: bolder; font-style: italic; color: #800000; background-
color: #FFFF66">
Product Details Based on Product Id</td>
</tr>
<tr>
<td align="center" class="style21"
style="font-size: x-large; font-weight: bold; font-style: normal; color: #800000">
Product Id :-</td>

ASP.NET Page 10
TMTBCA COLLEGE
</tr>
<tr>
<td align="center" class="style5">
<asp:TextBox ID="txtpid" runat="server" Height="42px" Width="241px"
Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" class="style23">
<asp:Button ID="btnshow" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="41px" Text="Display" Width="95px" />
</td>
</tr>
<tr>
<td align="center">
<br />
<asp:GridView ID="GridView2" runat="server" Height="192px" Width="750px"
BackColor="White" Font-Bold="True" Font-Size="25px" ForeColor="Maroon">
</asp:GridView>
<br />
<br />
</td>
</tr>
</table>
</asp:View>
<asp:View ID="View3" runat="server">
<table class="style1">
<tr>
<td align="center" class="style24"
style="font-size: 30px; font-weight: bolder; font-style: italic; color: #800000; background-
color: #FFFF66">
Display Of Product Details</td>
</tr>
<tr>
<td align="center" class="style26">
<asp:GridView ID="grid" runat="server" Height="215px" Width="736px"
BackColor="White" Font-Bold="True" Font-Size="25px" ForeColor="Maroon">
</asp:GridView>
</td>
</tr>
</table>
</asp:View>
</asp:MultiView>

ASP.NET Page 11
TMTBCA COLLEGE
</div>
</form>
</body>
</html>

[products.aspx] – Code View

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class products
Inherits System.Web.UI.Page
Dim con As New
SqlConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub btnins_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnins.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("insert into tblproduct values(@no,@name,@des,@price)",
con)
cmd.Parameters.Add("@no", SqlDbType.Int).Value = CInt(txtpno.Text)
cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = txtpname.Text
cmd.Parameters.Add("@des", SqlDbType.VarChar).Value = txtdes.Text
cmd.Parameters.Add("@price", SqlDbType.Decimal).Value = CDec(txtprice.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
MsgBox("Record Inserted Successfully.....", MsgBoxStyle.Information)
End If
End Sub

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


Handles btnupd.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("update tblproduct set
productname=@nm,description=@des,price=@price where productno=@pno", con)
cmd.Parameters.Add("@pno", SqlDbType.Int).Value = CInt(txtpno.Text)
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtpname.Text
cmd.Parameters.Add("@des", SqlDbType.VarChar).Value = txtdes.Text
cmd.Parameters.Add("@price", SqlDbType.Decimal).Value = CDec(txtprice.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()

ASP.NET Page 12
TMTBCA COLLEGE
MsgBox("Record Updated Successfully.....", MsgBoxStyle.Information)
End If
End Sub

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


Handles btndel.Click
Dim cmd As New SqlCommand("delete from tblproduct where productno=@pno", con)
cmd.Parameters.Add("@pno", SqlDbType.Int).Value = CInt(txtpno.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
MsgBox("Record Deleted Successfully.....", MsgBoxStyle.Information)
End Sub

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


Handles btndis.Click
MultiView1.ActiveViewIndex = 2
Dim cmd As New SqlCommand("select * from tblproduct", con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "product")
grid.DataSource = ds.Tables("product")
Page.DataBind()
End Sub

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


Handles btnrep.Click
MultiView1.ActiveViewIndex = 1
End Sub

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


Handles btnshow.Click
Dim cmd As New SqlCommand("select * from tblproduct where productno=@pno", con)
cmd.Parameters.Add("@pno", SqlDbType.Int).Value = CInt(txtpid.Text)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "pr")
GridView2.DataSource = ds.Tables("pr")
GridView2.DataBind()
End Sub
End Class

ASP.NET Page 13
TMTBCA COLLEGE

Roll No : 64
TYBCA Sem- 5 Div- B
Name : Rawal Prerana Maheshkumar

Application : 5
Create an application to maintain(Insert, update, delete and display) book details using
database.
Details of books to be managed are Book no, Name, Publisher, Publication Date, Price.
Author, Description and Category(Educational/Fiction/Non-Fiction)
Generate the following reports:

ASP.NET Page 14
TMTBCA COLLEGE
 Display all Educational Books Whose Publication date is the same as the date given
by the user.
 Display all books whose price falls within the range given by the user.

Solution:
[Web.Config]

<connectionStrings>
<add name="con" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\asp.net
websites\bookdatabaseex\App_Data\bookDatabase.mdf;Integrated Security=True;User
Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

[BookDetails.aspx] – Source View

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="BookDetail.aspx.vb"


Inherits="BookDetail" %>

<!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: 100%;
border: 4px solid #800000;
}
.style5
{
height: 77px;
}
.style8
{
height: 41px;
}
.style10
{
height: 42px;
}
.style12
{
height: 43px;
}

ASP.NET Page 15
TMTBCA COLLEGE
.style14
{
height: 44px;
}
.style16
{
height: 58px;
}
.style21
{
height: 44px;
width: 325px;
}
.style31
{
height: 65px;
}
.style32
{
height: 114px;
}
.style33
{
height: 83px;
}
.style34
{
height: 77px;
width: 514px;
}
.style35
{
height: 83px;
width: 514px;
}
.style36
{
width: 100%;
border:4px solid maroon;
}
.style37
{
}
.style39
{
height: 62px;
}
.style42
{

ASP.NET Page 16
TMTBCA COLLEGE
height: 41px;
width: 325px;
}
.style43
{
height: 42px;
width: 325px;
}
.style44
{
height: 43px;
width: 325px;
}
.style45
{
height: 62px;
width: 115px;
}
.style48
{
width: 6px;
}
.style49
{
height: 62px;
width: 35px;
}
.style50
{
width: 49px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:MultiView ID="MultiView2" runat="server" ActiveViewIndex="0">


<asp:View ID="View1" runat="server">
<table class="style1">
<tr>
<td align="center" class="style5" colspan="3"
style="font-size: 40pt; font-weight: bolder; color: #800000; font-style: italic;
background-color: #FFFF00">
Book Details</td>
</tr>
<tr>
<td class="style42"
style="font-size: xx-large; font-weight: bold; color: #800000">

ASP.NET Page 17
TMTBCA COLLEGE
Enter Book No</td>
<td class="style8"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtno" runat="server" Font-Bold="True" Font-
Size="25px"
Height="41px" Width="367px"></asp:TextBox>
</td>
<td class="style8"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtno" ErrorMessage="id is require.."
ForeColor="#CC0000"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style42"
style="font-size: xx-large; font-weight: bold; color: #800000">
Enter Book Name</td>
<td class="style8"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtname" runat="server" Font-Bold="True" Font-
Size="25px"
Height="36px" Width="365px"></asp:TextBox>
</td>
<td class="style8"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtname" ErrorMessage="name is require.."
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style42"
style="font-size: xx-large; font-weight: bold; color: #800000">
Enter Publisher Name</td>
<td class="style8"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtpname" runat="server" Font-Bold="True" Font-
Size="25px"
Height="35px" Width="365px"></asp:TextBox>
</td>
<td class="style8"
style="font-size: xx-large; font-weight: bold; color: #800000">
</td>
</tr>
<tr>
<td class="style43"
style="font-size: xx-large; font-weight: bold; color: #800000">

ASP.NET Page 18
TMTBCA COLLEGE
Enter Publication Date</td>
<td class="style10"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
<br />
<asp:TextBox ID="txtpdate" runat="server" Font-Bold="True" Font-
Size="25px"
Height="40px" Width="384px"></asp:TextBox>
</td>
<td class="style10"
style="font-size: xx-large; font-weight: bold; color: #800000">
</td>
</tr>
<tr>
<td class="style44"
style="font-size: xx-large; font-weight: bold; color: #800000">
Enter Price</td>
<td class="style12"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtprice" runat="server" Font-Bold="True" Font-
Size="25px"
Height="40px" Width="383px"></asp:TextBox>
</td>
<td class="style12"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtprice" ErrorMessage="price is require..."
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style21"
style="font-size: xx-large; font-weight: bold; color: #800000">
Enter Author Name</td>
<td class="style14"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtauthor" runat="server" Font-Bold="True" Font-
Size="25px"
Height="37px" Width="381px"></asp:TextBox>
</td>
<td class="style14"
style="font-size: xx-large; font-weight: bold; color: #800000">
</td>
</tr>
<tr>
<td class="style43"
style="font-size: xx-large; font-weight: bold; color: #800000">
Enter Description</td>
<td class="style10"

ASP.NET Page 19
TMTBCA COLLEGE
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtdesc" runat="server" Font-Bold="True" Font-
Size="25px"
Height="34px" Width="381px"></asp:TextBox>
</td>
<td class="style10"
style="font-size: xx-large; font-weight: bold; color: #800000">
</td>
</tr>
<tr>
<td class="style44"
style="font-size: xx-large; font-weight: bold; color: #800000">
Select Category</td>
<td class="style12"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:DropDownList ID="ddlcat" runat="server" Font-Bold="True" Font-
Size="25px"
Height="35px" Width="379px">
<asp:ListItem>Educational</asp:ListItem>
<asp:ListItem>Fiction</asp:ListItem>
<asp:ListItem>Non-Fiction</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style12"
style="font-size: xx-large; font-weight: bold; color: #800000">
</td>
</tr>
<tr>
<td class="style16" colspan="3"
style="font-size: xx-large; font-weight: bold; color: #800000">
&nbsp;<asp:Button ID="btnins" runat="server" BackColor="Maroon"
Font-Bold="True"
Font-Size="25px" ForeColor="White" Height="42px" Text="Insert"
Width="125px" />
&nbsp;
<asp:Button ID="btnupd" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="25px" ForeColor="White" Height="41px" Text="Update"
Width="124px" />
&nbsp;
<asp:Button ID="btndel" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="25px" ForeColor="White" Height="40px" Text="Delete"
Width="126px" />
&nbsp;
<asp:Button ID="btndisp" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="25px" ForeColor="White" Height="40px" Text="Display"
Width="121px" CausesValidation="False" />

ASP.NET Page 20
TMTBCA COLLEGE
&nbsp;
<asp:Button ID="btnreset" runat="server" BackColor="Maroon"
CausesValidation="False" Font-Bold="True" Font-Size="25px"
ForeColor="White"
Height="40px" Text="Reset" Width="118px" />
&nbsp;
<asp:Button ID="btnrep1" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="20px" ForeColor="White" Height="40px" Text=" Input
DateReport"
Width="179px" CausesValidation="False" />
&nbsp;
<asp:Button ID="btnrep2" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="20px" ForeColor="White" Height="37px" Text="Price
Range Report"
Width="211px" CausesValidation="False" />
<br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ForeColor="Red"
HeaderText="Errors ::--" Height="106px" Width="807px" />
<br />
</td>
</tr>
</table>
</asp:View>
<asp:View ID="View2" runat="server">
<table class="style1">
<tr>
<td align="center" class="style31"
style="font-size: 40pt; font-weight: bolder; color: #800000; font-style: italic;
background-color: #FFFF00">
Display Of Book Details</td>
</tr>
<tr>
<td align="center" class="style32"
style="font-size: xx-large; font-weight: bold; color: #800000">
<br />
<asp:GridView ID="GridView1" runat="server" Width="547px">
</asp:GridView>
</td>
</tr>
</table>
</asp:View>
<asp:View ID="View3" runat="server">
<table class="style1">
<tr>
<td align="center" class="style34"

ASP.NET Page 21
TMTBCA COLLEGE
style="font-size: 40pt; font-weight: bolder; color: #800000; font-style: italic;
background-color: #FFFF00">
Select Date</td>
<td align="center" class="style5"
style="font-size: 40pt; font-weight: bolder; color: #800000; font-style: italic;
background-color: #FFFF00">
Details Of Inputed Date</td>
</tr>
<tr>
<td class="style35"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:Calendar ID="Calendar2" runat="server"></asp:Calendar>
<asp:TextBox ID="txtvdate" runat="server" Font-Bold="True" Font-
Size="25px"
Height="43px" Width="490px"></asp:TextBox>
<br />
<asp:Button ID="btndis" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="25px" ForeColor="White" Height="43px" Text="Display" Width="114px" />
<br />
&nbsp;</td>
<td class="style33"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:GridView ID="GridView3" runat="server" Width="495px">
</asp:GridView>
</td>
</tr>
</table>
</asp:View>
<asp:View ID="View4" runat="server">
<table class="style36">
<tr>
<td class="style45" style="border-style: 4; border-color: 4; font-size: xx-large;
font-weight: bold; color: #800000">from</td>
<td class="style49"
style="border-style: 4; border-color: 4; font-size: xx-large; font-weight:
bold; color: #800000"
align="center">
<asp:TextBox ID="txtfrom" runat="server" Height="40px"
Width="240px"></asp:TextBox>
</td>
<td class="style50" style="border-style: 4; border-color: 4; font-size: xx-large;
font-weight: bold; color: #800000" align="center">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtfrom" ErrorMessage="Please enter from range."
Font-Size="25px" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
<td class="style37" rowspan="3"

ASP.NET Page 22
TMTBCA COLLEGE
style="border-style: 4; border-color: 4; font-size: xx-large; font-weight:
bold; color: #800000"
align="center">
As Per Price Range Details Of Book<br />
<br />
<asp:GridView ID="GridView4" runat="server" Width="580px">
</asp:GridView>
</td>
</tr>
<tr>
<td class="style45" style="border-style: 4; border-color: 4; font-size: xx-large;
font-weight: bold; color: #800000">
to
</td>
<td class="style49"
style="border-style: 4; border-color: 4; font-size: xx-large; font-weight:
bold; color: #800000"
align="center">
<asp:TextBox ID="txtto" runat="server" Height="38px"
Width="242px"></asp:TextBox>
</td>
<td class="style50"
style="border-style: 4; border-color: 4; font-size: xx-large; font-weight:
bold; color: #800000"
align="center">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="txtto" ErrorMessage="Please enter to range."
Font-Size="25px" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style39" colspan="3" style="border-style: 4; border-color: 4; font-
size: xx-large; font-weight: bold; color: #800000">
<asp:Button ID="btnshow" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="25px" ForeColor="White" Height="44px" Text="Show" Width="96px" />
&nbsp;</td>
</tr>
</table>
</asp:View>
</asp:MultiView>
</div>
</form>
</body>
</html>

[BookDetails.aspx] – Code View

ASP.NET Page 23
TMTBCA COLLEGE

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class BookDetail
Inherits System.Web.UI.Page
Dim con As New
SqlConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)

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


Handles btnins.Click
If Page.IsValid Then
Dim cmd As New SqlCommand("insert into tblbook
values(@no,@nm,@pname,@pdate,@price,@athr,@des,@cat)", con)
cmd.Parameters.Add("@no", SqlDbType.Int).Value = CInt(txtno.Text)
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtname.Text
cmd.Parameters.Add("@pname", SqlDbType.VarChar).Value = txtpname.Text
cmd.Parameters.Add("@pdate", SqlDbType.Date).Value = CDate(txtpdate.Text)
cmd.Parameters.Add("@price", SqlDbType.Decimal).Value = CDec(txtprice.Text)
cmd.Parameters.Add("@athr", SqlDbType.VarChar).Value = txtauthor.Text
cmd.Parameters.Add("@des", SqlDbType.VarChar).Value = txtdesc.Text
cmd.Parameters.Add("@cat", SqlDbType.VarChar).Value = ddlcat.SelectedValue
con.Open()
cmd.ExecuteNonQuery()
con.Close()
MsgBox("inserted successfully")
End If
End Sub

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


Handles btnupd.Click
Dim cmd As New SqlCommand("update tblbook set
name=@nm,publisher=@pname,publictiondate=@pdate,price=@price,author=@athr,descrip
tion=@des,category=@cat where bookno=@no", con)
cmd.Parameters.Add("@no", SqlDbType.Int).Value = CInt(txtno.Text)
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtname.Text
cmd.Parameters.Add("@pname", SqlDbType.VarChar).Value = txtpname.Text
cmd.Parameters.Add("@pdate", SqlDbType.Date).Value = CDate(txtpdate.Text)
cmd.Parameters.Add("@price", SqlDbType.Decimal).Value = CDec(txtprice.Text)
cmd.Parameters.Add("@athr", SqlDbType.VarChar).Value = txtauthor.Text
cmd.Parameters.Add("@des", SqlDbType.VarChar).Value = txtdesc.Text
cmd.Parameters.Add("@cat", SqlDbType.VarChar).Value = ddlcat.SelectedValue
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Response.Write("records updated successfully")
End Sub

ASP.NET Page 24
TMTBCA COLLEGE
Protected Sub btndel_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btndel.Click
Dim cmd As New SqlCommand("delete from tblbook where bookno=@no", con)
cmd.Parameters.Add("@no", SqlDbType.Int).Value = CInt(txtno.Text)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Response.Write("records deleted successfully")
End Sub

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


Handles btndisp.Click
MultiView2.ActiveViewIndex = 1
End Sub

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


Handles btnrep1.Click
MultiView2.ActiveViewIndex = 2
End Sub

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


Handles btnrep2.Click
MultiView2.ActiveViewIndex = 3
End Sub

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


Handles btnreset.Click
txtauthor.Text = ""
ddlcat.Text = ""
txtdesc.Text = ""
txtno.Text = ""
txtpdate.Text = ""
txtpname.Text = ""
txtprice.Text = ""
txtname.Text = ""
End Sub

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Calendar1.SelectionChanged
txtpdate.Text = Calendar1.SelectedDate
End Sub

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


Handles btndis.Click
Dim cmd As New SqlCommand("select * from tblbook where
publictiondate=@idate", con)
cmd.Parameters.Add("@idate", SqlDbType.Date).Value = CDate(txtvdate.Text)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet

ASP.NET Page 25
TMTBCA COLLEGE
da.Fill(ds, "sbook")
GridView3.DataSource = ds.Tables("sbook")
Page.DataBind()
End Sub

Protected Sub Calendar2_SelectionChanged(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Calendar2.SelectionChanged
txtvdate.Text = Calendar1.SelectedDate
End Sub

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


Handles btnshow.Click
Dim cmd As New SqlCommand("select * from tblbook where price>=@from and
price<=@to", con)
cmd.Parameters.Add("@from", SqlDbType.Decimal).Value = txtfrom.Text
cmd.Parameters.Add("@to", SqlDbType.Decimal).Value = txtto.Text
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "pbook")
GridView4.DataSource = ds.Tables("pbook")
GridView4.DataBind()

End Sub

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


Handles Me.Load
Dim cmd As New SqlCommand("select * from tblbook", con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "dbook")
GridView1.DataSource = ds.Tables("dbook")
Page.DataBind()
End Sub
End Class

ASP.NET Page 26
TMTBCA COLLEGE

Roll No : 64
TYBCA Sem- 5 Div- B
Name : Rawal Prerana Maheshkumar

Application : 6
Create an application to simulate login controls using the database.

Solution:
[Web.Config]

<connectionStrings >
<add name ="con" connectionString ="Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\asp.net

ASP.NET Page 27
TMTBCA COLLEGE
websites\loginsimulationex\App_Data\logdb.mdf;Integrated Security=True;User
Instance=True" providerName ="System.SqlClient"/>
</connectionStrings>

[Default.aspx] – Source View

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"


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>
<style type="text/css">
.style1
{
width: 100%;
border: 2px solid #800000;
background-color: #FFFFFF;
}
.style4
{
width: 298px;
}
.style5
{
width: 100%;
border:3px solid red
}
.style10
{
width: 100%;
border: 3px solid #CC0000;
}
.style11
{
}
.style12
{
width: 383px;
}
.style15
{
height: 35px;
}
.style16

ASP.NET Page 28
TMTBCA COLLEGE
{
width: 346px;
}
.style20
{
width: 100%;
border: 3px solid #800000;
}
.style21
{
height: 92px;
}
.style24
{
width: 281px;
}
.style25
{
height: 73px;
}
.style26
{
width: 127px;
}
.style29
{
width: 59px;
}
.style30
{
height: 71px;
}
.style31
{
height: 125px;
}
.style33
{
height: 82px;
}
.style34
{
width: 357px;
}
.style35
{
width: 350px;
}
.style38

ASP.NET Page 29
TMTBCA COLLEGE
{
width: 319px;
}
.style39
{
width: 418px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="2">


<asp:View ID="View1" runat="server">
<table cellpadding="2" cellspacing="4" class="style1">
<tr>
<td class="style21"

style="font-size: 40pt; font-weight: bolder; font-style: italic; color: #800000;


background-color: #00FFFF;"
align="center" colspan="3">
Registration</td>
</tr>
<tr>
<td class="style24"
style="font-size: xx-large; font-weight: bold; color: #800000">
Username</td>
<td class="style4"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtuname" runat="server" Height="38px"
ToolTip="Enter Username" Width="274px" Font-Bold="True" Font-
Size="25px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtuname"
ErrorMessage="This field is Mandatory to register yourself."
ForeColor="#CC0000"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style24"
style="font-size: xx-large; font-weight: bold; color: #800000">
Password</td>
<td class="style4"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtpwd" runat="server" Height="35px" Width="267px"

ASP.NET Page 30
TMTBCA COLLEGE
TextMode="Password" Font-Bold="True" Font-Size="25px"
ToolTip="Enter Password"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="txtpwd"
ErrorMessage="This field is Mandatory to register yourself."
ForeColor="#CC0000"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style24"
style="font-size: xx-large; font-weight: bold; color: #800000">
Confirm Password</td>
<td class="style4"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtcpwd" runat="server" Height="34px"
Width="268px"
Font-Bold="True" Font-Size="25px"
TextMode="Password"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtpwd" ControlToValidate="txtcpwd"
ErrorMessage="Please enter the correct password."
ForeColor="#CC0000"
SetFocusOnError="True">*</asp:CompareValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtcpwd"
ErrorMessage="This field is Mandatory to register yourself."
ForeColor="#CC0000"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style24"
style="font-size: xx-large; font-weight: bold; color: #800000">
Email</td>
<td class="style4"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtmail" runat="server" Height="34px"
ToolTip="Enter your email id" Width="264px" Font-Bold="True"
Font-Size="25px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
&nbsp;</td>
</tr>
<tr>

ASP.NET Page 31
TMTBCA COLLEGE
<td class="style24"
style="font-size: xx-large; font-weight: bold; color: #800000">
Security Question</td>
<td class="style4"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtsec" runat="server" Height="33px"
ToolTip="Enter any question." Width="261px" Font-Bold="True"
Font-Size="25px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtsec" ErrorMessage="This field is Mandatory to
register yourself."
ForeColor="#CC0000"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style24"
style="font-size: xx-large; font-weight: bold; color: #800000">
Answer</td>
<td class="style4"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtans" runat="server" Font-Bold="True" Font-
Size="25px"
Height="35px" ToolTip="Enter an respected answer"
Width="262px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtans" ErrorMessage="RequiredFieldValidator"
ForeColor="#CC0000"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style22"
style="font-size: xx-large; font-weight: bold; color: #800000" colspan="3">
<asp:Button ID="btnsub" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="25px" ForeColor="White" Height="48px" Text="Create"
Width="97px" /></td>
</tr>
<tr>
<td class="style23" colspan="3"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ForeColor="Red"
HeaderText=":: Following Errors ::" />

ASP.NET Page 32
TMTBCA COLLEGE
</td>
</tr>
</table>
<br />
</asp:View>
<asp:View ID="View2" runat="server">
<strong style="font-size: xx-large; font-weight: bolder; font-style: normal; color:
#800000">
<asp:Label ID="lbluname" runat="server"></asp:Label>
&nbsp;Successfully Registered</strong><br />
<asp:Button ID="btncontinue" runat="server" BackColor="Maroon"
BorderColor="Black" Font-Bold="True" Font-Size="25px" ForeColor="White"
Height="48px" Text="Continue" Width="125px" />
<br />
</asp:View>
<asp:View ID="View3" runat="server">
<table class="style5">
<tr>
<td class="style25"

style="font-size: 40pt; font-weight: bolder; font-style: italic; color: #800000;


background-color: #00FFFF;"
align="center" colspan="3">
Login</td>
</tr>
<tr>
<td class="style26"
style="font-size: xx-large; font-weight: bold; color: #800000">
Username</td>
<td class="style29"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtluname" runat="server" Height="36px"
Width="436px"
Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
BackColor="White" ControlToValidate="txtluname"
ErrorMessage="This is a required field."
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style26"
style="font-size: xx-large; font-weight: bold; color: #800000">
Password</td>
<td class="style29"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtlpwd" runat="server" Height="37px" Width="436px"

ASP.NET Page 33
TMTBCA COLLEGE
TextMode="Password" Font-Bold="True" Font-
Size="25px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ControlToValidate="txtlpwd" ErrorMessage="This is a required field."
ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style6"
style="font-size: xx-large; font-weight: bold; color: #800000" colspan="3">
<asp:Button ID="btnlog" runat="server" BackColor="#CC0000"
Font-Bold="True" Font-Size="25px" ForeColor="White" Height="41px"
Text="Login"
Width="94px" />
&nbsp;&nbsp;
<asp:Button ID="btnlres" runat="server" BackColor="#CC0000"
CausesValidation="False" Font-Bold="True" Font-Size="25px"
ForeColor="White"
Height="44px" Text="Reset" Width="104px" />
&nbsp;&nbsp;&nbsp;<asp:LinkButton ID="lbforgot" runat="server"
CausesValidation="False"
ForeColor="#3333CC">Password Recovery</asp:LinkButton>
&nbsp; &nbsp;
<asp:LinkButton ID="lbreg" runat="server" CausesValidation="False"
ForeColor="#3333CC">Registration</asp:LinkButton>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="lblumsg" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="style6"
style="font-size: xx-large; font-weight: bold; color: #800000" colspan="2">
<asp:ValidationSummary ID="ValidationSummary2" runat="server"
ForeColor="Red"
HeaderText=":: Errors ::" />
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
&nbsp;</td>
</tr>
</table>
</asp:View>
<asp:View ID="View4" runat="server">
<table class="style10">
<tr>
<td align="center" colspan="3"

ASP.NET Page 34
TMTBCA COLLEGE
style="font-size: 40pt; font-weight: bolder; font-style: italic; color: #800000;
background-color: #00FFFF;"
class="style30">
Forgot Password<br />
</td>
</tr>
<tr>
<td class="style35"
style="font-size: xx-large; font-weight: bold; color: #800000">
Enter Your Username </td>
<td class="style12"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtfuname" runat="server" Height="40px"
Width="330px"
Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
ControlToValidate="txtfuname"
ErrorMessage="This is Mandatory field to get your password."
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style31" style="font-size: xx-large; font-weight: bold; color:
#800000" colspan="3">
<asp:Button ID="btnshwpwd" runat="server" BackColor="#CC0000" Font-
Bold="True" Font-Size="18px" ForeColor="White" Height="51px" Text="Submit"
Width="151px" />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
<br />
</td>
</tr>
<tr>
<td class="style11" colspan="3" style="font-size: xx-large; font-weight: bold;
color: #800000">&nbsp;</td>
</tr>
</table>
</asp:View>
<asp:View ID="View5" runat="server">
<table class="style10">
<tr>
<td align="center" colspan="3" style="font-size: 40pt; font-weight: bolder;
font-style: italic; color: #800000; background-color: #00FFFF;"
class="style33">
Change Password</td>
</tr>
<tr>

ASP.NET Page 35
TMTBCA COLLEGE
<td class="style34" style="font-size: xx-large; font-weight: bold; color:
#800000">Password</td>
<td class="style16" style="font-size: xx-large; font-weight: bold; color:
#800000">
<asp:TextBox ID="txtopwd" runat="server" Height="35px" TextMode="Password"
Width="360px" Font-Bold="True" Font-Size="25px"></asp:TextBox></td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"
ControlToValidate="txtopwd" ErrorMessage="THIS IS REQUIRED FIELD."
ForeColor="Red">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="style34" style="font-size: xx-large; font-weight: bold; color:
#800000">Change Password</td>
<td class="style16" style="font-size: xx-large; font-weight: bold; color:
#800000">
<asp:TextBox ID="txtnpwd" runat="server" Height="35px"
TextMode="Password" Width="363px" Font-Bold="True" Font-
Size="25px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server"
ControlToValidate="txtnpwd" ErrorMessage="THIS IS REQUIRED FIELD."
ForeColor="Red">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="style34" style="font-size: xx-large; font-weight: bold; color:
#800000">Confirm New Password</td>
<td class="style16" style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtncpwd" runat="server" Height="35px"
TextMode="Password" Width="362px" Font-Bold="True" Font-
Size="25px"></asp:TextBox></td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator11"
runat="server" ControlToValidate="txtncpwd" ErrorMessage="THIS IS REQUIRED
FIELD." ForeColor="Red">*</asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator3" runat="server"
ControlToCompare="txtnpwd" ControlToValidate="txtncpwd"
ErrorMessage="Confirm Password must be matched to password."
ForeColor="Red">*</asp:CompareValidator>
</td>
</tr>
<tr>
<td class="style13" colspan="3"
style="font-size: xx-large; font-weight: bold; color: #800000">
&nbsp;</td>
</tr>
<tr>
<td class="style15" colspan="3"

ASP.NET Page 36
TMTBCA COLLEGE
style="font-size: xx-large; font-weight: bold; color: #800000">
Confirm New Password Must Match To new Password Entry.</td>
</tr>
<tr>
<td class="style17" colspan="3" style="font-size: xx-large; font-weight: bold;
color: #800000">
<asp:Button ID="btncps" runat="server" BackColor="#CC0000" Font-Bold="True"
Font-Size="17px" ForeColor="White" Height="49px" Text="Change Password"
Width="168px" />
<asp:Button ID="btncancel" runat="server" BackColor="#CC0000" ForeColor="White"
Height="49px" Text="Cancel" Width="127px" Font-Bold="True" Font-Size="20px" /></td>
</tr>
<tr>
<td class="style18" colspan="3" style="font-size: xx-large; font-weight: bold;
color: #800000">
<asp:ValidationSummary ID="ValidationSummary3" runat="server" /> </td>
</tr>
</table>
</asp:View>
<asp:View ID="View6" runat="server"> &nbsp;<table class="style20">
<tr>
<td style="font-size: 30pt; font-weight: bolder; font-style: normal; color:
#800000"><strong>your password is successfully changed from
<asp:Label ID="lblopswd" runat="server" Text="Label"></asp:Label>&nbsp;to
asp:Label ID="lblnpswd" runat="server" Text="Label"></asp:Label></strong>.</td>
</tr>
</table>
<strong>
<br />
</strong>
</asp:View>
<asp:View ID="View7" runat="server">
<table class="style20">
<tr>
<td style="font-size: xx-large; font-weight: bold; color: #800000">Welcome
<asp:Literal ID="lituser" runat="server"></asp:Literal>
<br />
<br />
<asp:LinkButton ID="lblogout" runat="server">LogOut</asp:LinkButton>
<asp:LinkButton ID="lbcp" runat="server" CausesValidation="False"
ForeColor="#3333CC">Change Password</asp:LinkButton></td>
</tr>
</table>
</asp:View>
<asp:View ID="View8" runat="server">
<table class="style20">
<tr>
<td class="style39" style="font-size: xx-large; font-weight: bold; color:
#800000">UserName</td>

ASP.NET Page 37
TMTBCA COLLEGE
<td colspan="2" style="font-size: xx-large; font-weight: bold; color:
#800000"><asp:Label ID="lblcuname" runat="server"></asp:Label></td>
</tr>
<tr>
<td class="style39" style="font-size: xx-large; font-weight: bold; color:
#800000">
<asp:Label ID="lblque" runat="server"></asp:Label></td>
<td class="style38"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtchans" runat="server" Height="34px"
TextMode="MultiLine"
Width="304px" Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator12"
runat="server"
ControlToValidate="txtchans" ErrorMessage="Please enter answer."
ForeColor="Red"
SetFocusOnError="True"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style36" colspan="3"
style="font-size: xx-large; font-weight: bold; color: #800000">
<asp:Button ID="btnget" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="25px" ForeColor="White" Height="36px" Text="Get"
Width="94px" />
<asp:Label ID="lblqs" runat="server"></asp:Label>
</td>
</tr>
</table>
</asp:View>
<asp:View ID="View9" runat="server">
<table class="style20">
<tr>
<td style="font-size: xx-large; font-weight: bold; color: #800000">
Your Passsword&nbsp;
<asp:Label ID="lblpash" runat="server"></asp:Label>
<br />
<asp:Button ID="btnget0" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="25px" ForeColor="White" Height="38px" Text="continue"
Width="113px" />
</td>
</tr>
</table>
</asp:View>
</asp:MultiView>

ASP.NET Page 38
TMTBCA COLLEGE
</div>
</form>
</body>
</html>

[Default.aspx] – Code View

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Dim dr As SqlDataReader
Dim con As New
SqlConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)

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


Handles btnsub.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("insert into tbllog
values(@nm,@pwd,@cpwd,@mail,@sec,@ans)", con)
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtuname.Text
cmd.Parameters.Add("@pwd", SqlDbType.VarChar).Value = txtpwd.Text
cmd.Parameters.Add("@cpwd", SqlDbType.VarChar).Value = txtcpwd.Text
cmd.Parameters.Add("@mail", SqlDbType.VarChar).Value = txtmail.Text
cmd.Parameters.Add("@sec", SqlDbType.VarChar).Value = txtsec.Text
cmd.Parameters.Add("@ans", SqlDbType.VarChar).Value = txtans.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
MultiView1.ActiveViewIndex = 1
Session("uname") = txtuname.Text
lbluname.Text = Session("uname")
End If
End Sub

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


Handles btncontinue.Click
MultiView1.ActiveViewIndex = 2
End Sub

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


Handles btnlog.Click
If Page.IsValid Then
Dim cmd As New SqlCommand("select count(*) from tbllog where username=@un
and password=@pwd", con)
cmd.Parameters.Add("@un", SqlDbType.VarChar).Value = txtluname.Text

ASP.NET Page 39
TMTBCA COLLEGE
cmd.Parameters.Add("@pwd", SqlDbType.VarChar).Value = txtlpwd.Text
con.Open()
If (cmd.ExecuteScalar() > 0) Then
Session("uname") = txtluname.Text
MultiView1.ActiveViewIndex = 6
lituser.Text = Session("uname")
Else
lblumsg.Text = "User does not exists"
End If
End If
End Sub

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


Handles btnlres.Click
txtluname.Text = ""
txtlpwd.Text = ""
End Sub

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


Handles lbforgot.Click
MultiView1.ActiveViewIndex = 3
End Sub

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


Handles btnshwpwd.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("select * from tbllog where username=@unm", con)
cmd.Parameters.Add("@unm", SqlDbType.VarChar).Value = txtfuname.Text
con.Open()

dr = cmd.ExecuteReader
If dr.Read Then
lblcuname.Text = txtfuname.Text
lblque.Text = dr.Item("security_question")
MultiView1.ActiveViewIndex = 7
Else
lblumsg.Text = "User does not exists"
End If
con.Close()
End If
End Sub

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


Handles lbcp.Click
MultiView1.ActiveViewIndex = 4
End Sub

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


Handles btncps.Click

ASP.NET Page 40
TMTBCA COLLEGE
If Page.IsValid = True Then
Dim cmd As New SqlCommand("update tbllog set
password=@npwd,confirm_password=@ncpwd where password=@opwd", con)
cmd.Parameters.Add("@opwd", SqlDbType.VarChar).Value = txtopwd.Text
cmd.Parameters.Add("@npwd", SqlDbType.VarChar).Value = txtnpwd.Text
cmd.Parameters.Add("@ncpwd", SqlDbType.VarChar).Value = txtncpwd.Text
con.Open()
cmd.ExecuteNonQuery()
MsgBox("password successfully changed....")
Session("oldpassword") = txtopwd.Text
Session("newpassword") = txtnpwd.Text
lblopswd.Text = Session("oldpassword")
lblnpswd.Text = Session("newpassword")
MultiView1.ActiveViewIndex = 5
con.Close()
End If
End Sub

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


Handles lbreg.Click
MultiView1.ActiveViewIndex = 0
End Sub

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


Handles lblogout.Click
MultiView1.ActiveViewIndex = 2
Session.Abandon()
txtluname.Text = ""
txtlpwd.Text = ""
End Sub

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


Handles btnget.Click
Dim cmd As New SqlCommand("select count(*),password from tbllog where
username=@user and answer=@answ group by username,password", con)
cmd.Parameters.Add("@user", SqlDbType.VarChar).Value = txtfuname.Text
cmd.Parameters.Add("@answ", SqlDbType.VarChar).Value = txtchans.Text
con.Open()
dr = cmd.ExecuteReader
If dr.Read Then
If dr.GetSqlInt32(0) = 1 Then
lblpash.Text = dr.GetString(1)
MultiView1.ActiveViewIndex = 8
End If
End If
End Sub

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


Handles btnget0.Click

ASP.NET Page 41
TMTBCA COLLEGE
MultiView1.ActiveViewIndex = 2
End Sub
End Class

ASP.NET Page 42
TMTBCA COLLEGE

Roll No : 64
TYBCA Sem- 5 Div- B
Name : Rawal Prerana Maheshkumar

Application : 7
Create an application to maintain car and its company info.
1) Provide Insert, Update, Delete and Display Facility for car and its company.
2) Generate company wise report of the car.

Solution:
[Web.Config]

<connectionStrings>
<add name="con" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\asp.net websites\car
website\App_Data\CarDb.mdf;Integrated Security=True;User Instance=True"
providerName="System.SqlClient"/>
</connectionStrings>

[car.aspx] – Source View

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"


AutoEventWireup="false" CodeFile="car.aspx.vb" Inherits="car" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">


<style type="text/css">
.style5
{
width: 70%;
border: 4px solid #800000;
margin-left :20px;

ASP.NET Page 43
TMTBCA COLLEGE
}
.style6
{
height: 53px;
}
.style8
{
width: 406px;
}
.style9
{
width: 282px;
}
.style10
{
height: 48px;
}
.style11
{
width: 45px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<table class="style5">
<tr>
<td align="center" class="style6" colspan="3"
style="font-size: xx-large; font-weight: bold; color: #800000; background-color:
#9999FF">
Car Details</td>
</tr>
<tr>
<td class="style8"
style="font-size: x-large; font-weight: bold; color: #800000">
Enter Car Id</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtno" runat="server" Font-Bold="True" Font-Size="30px"
Height="39px" Width="557px"></asp:TextBox>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000"
class="style11">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtno" ErrorMessage="Please enter car number."
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>

ASP.NET Page 44
TMTBCA COLLEGE
<td class="style8"
style="font-size: x-large; font-weight: bold; color: #800000">
Enter Car Name</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtname" runat="server" Font-Bold="True" Font-
Size="30px"
Height="37px" Width="552px"></asp:TextBox>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000"
class="style11">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtname" ErrorMessage="Please enter car name."
Font-Bold="True" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style8"
style="font-size: x-large; font-weight: bold; color: #800000">
Enter car color</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtcolor" runat="server" Font-Bold="True" Font-
Size="30px"
Height="36px" Width="551px"></asp:TextBox>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000"
class="style11">
&nbsp;</td>
</tr>
<tr>
<td class="style8"
style="font-size: x-large; font-weight: bold; color: #800000">
Enter No of Seats</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtseats" runat="server" Font-Bold="True" Font-
Size="30px"
Height="40px" Width="554px"></asp:TextBox>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000"
class="style11">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtseats"
ErrorMessage="Please enter number of seats car have." ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>

ASP.NET Page 45
TMTBCA COLLEGE
<tr>
<td class="style8"
style="font-size: x-large; font-weight: bold; color: #800000">
Enter Price</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtprice" runat="server" Font-Bold="True" Font-
Size="30px"
Height="36px" Width="558px"></asp:TextBox>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000"
class="style11">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtprice" ErrorMessage="please enter price of car."
Font-Bold="True" ForeColor="Red">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style8"
style="font-size: x-large; font-weight: bold; color: #800000">
select Company Id&nbsp;</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:DropDownList ID="ddlcid" runat="server" Font-Bold="True" Font-
Size="25px"
Height="45px" Width="557px">
</asp:DropDownList>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000"
class="style11">
&nbsp;</td>
</tr>
<tr>
<td class="style10" colspan="3"
style="font-size: x-large; font-weight: bold; color: #800000">
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnins" runat="server" Height="43px" Text="Insert"
Width="97px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnupd" runat="server" Height="44px" Text="Update"
Width="100px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btndel" runat="server" Height="43px" Text="Delete"
Width="106px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

ASP.NET Page 46
TMTBCA COLLEGE
<asp:Button ID="btndis" runat="server" CausesValidation="False"
Height="44px"
Text="Display" Width="93px" BackColor="Yellow" Font-Bold="True"
Font-Size="18px" ForeColor="#FF0066" />
</td>
</tr>
<tr>
<td class="style10" colspan="3"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" Font-
Bold="True"
Font-Size="30px" />
</td>
</tr>
</table>
</asp:Content>

[car.aspx] – Code View

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class car
Inherits System.Web.UI.Page
Dim con As New
SqlConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub btnins_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnins.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("insert into tbcar
values(@no,@nm,@clr,@seats,@price,@compnm)", con)
cmd.Parameters.Add("@no", SqlDbType.VarChar).Value = txtno.Text
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtname.Text
cmd.Parameters.Add("@clr", SqlDbType.VarChar).Value = txtcolor.Text
cmd.Parameters.Add("@price", SqlDbType.Decimal).Value = CDec(txtprice.Text)
cmd.Parameters.Add("@seats", SqlDbType.Int).Value = CInt(txtseats.Text)
cmd.Parameters.Add("@compnm", SqlDbType.VarChar).Value = ddlcomp.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End If
MsgBox("record inserted successfully.......")
End Sub

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e


As System.EventArgs) Handles ddlcomp.SelectedIndexChanged

End Sub

ASP.NET Page 47
TMTBCA COLLEGE
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If Not IsPostBack Then
Dim cmd As New SqlCommand("select company_name from company", con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "id")
Dim cnt As Integer = CInt(ds.Tables("id").Rows.Count())
MsgBox(cnt.ToString)
If ds.Tables("id").Rows.Count > 0 Then
Me.ddlcomp.Items.Clear()

For i As Integer = 0 To cnt - 1


ddlcomp.Items.Add(ds.Tables("id").Rows(i)(0))
Next
End If
End If
End Sub

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


Handles btnupd.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("update car set
tbcar_name=@nm,color=@clr,no_of_seats=@seats,price=@price,company_name=@cmn
where car_no=@no", con)
cmd.Parameters.Add("@no", SqlDbType.VarChar).Value = txtno.Text
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtname.Text
cmd.Parameters.Add("@clr", SqlDbType.VarChar).Value = txtcolor.Text
cmd.Parameters.Add("@price", SqlDbType.Decimal).Value = CDec(txtprice.Text)
cmd.Parameters.Add("@seats", SqlDbType.Int).Value = CInt(txtseats.Text)
cmd.Parameters.Add("@cmn", SqlDbType.VarChar).Value = ddlcomp.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End If
MsgBox("record updated successfully.......")
End Sub

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


Handles btndel.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("delete from car where car_no=@no", con)
cmd.Parameters.Add("@no", SqlDbType.VarChar).Value = txtno.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End If
MsgBox("record deleted successfully.......")
End Sub

ASP.NET Page 48
TMTBCA COLLEGE

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


Handles btndis.Click
Response.Redirect("DisplayCar.aspx")
End Sub
End Class

[company.aspx] – Source View

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"


AutoEventWireup="false" CodeFile="company.aspx.vb" Inherits="company" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">


<style type="text/css">
.style5
{
width: 70%;
border: 4px solid #800000;
margin-left :140px;
}
.style6
{
height: 62px;
}
.style7
{
width: 245px;
}
.style8
{
height: 44px;
}
.style9
{
width: 440px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<table class="style5">
<tr>
<td align="Center" class="style6" colspan="3"
style="font-size: xx-large; font-weight: bold; color: #800000; background-color:
#9999FF;">
Company Details</td>
</tr>
<tr>
<td class="style7"

ASP.NET Page 49
TMTBCA COLLEGE
style="font-size: x-large; font-weight: bold; color: #800000">
Enter Company Name</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtcname" runat="server" Height="34px" Width="429px"
Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txtcname"
ErrorMessage="Please select company name of which car is."
ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style7"
style="font-size: x-large; font-weight: bold; color: #800000">
Enter Company Type</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:DropDownList ID="ddlcomtype" runat="server" Font-Bold="True"
Font-Size="30px" Height="41px" Width="440px">
<asp:ListItem>Private Limited</asp:ListItem>
<asp:ListItem>Public Limited</asp:ListItem>
</asp:DropDownList>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ControlToValidate="ddlcomtype" ErrorMessage="Please select company
type."
Font-Bold="True" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style7"
style="font-size: x-large; font-weight: bold; color: #800000">
Enter Founder Name</td>
<td class="style9"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:TextBox ID="txtfounder" runat="server" Height="34px" Width="438px"
Font-Bold="True" Font-Size="25px"></asp:TextBox>
</td>
<td style="font-size: x-large; font-weight: bold; color: #800000">
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"
ControlToValidate="txtfounder" ErrorMessage="please enter founder name"
Font-Bold="True" ForeColor="Red"
SetFocusOnError="True">*</asp:RequiredFieldValidator>

ASP.NET Page 50
TMTBCA COLLEGE
</td>
</tr>
<tr>
<td class="style8" colspan="3"
style="font-size: x-large; font-weight: bold; color: #800000">
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnins" runat="server" Height="43px" Text="Insert"
Width="97px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
&nbsp;&nbsp;&nbsp;
<asp:Button ID="btnupd" runat="server" Height="44px" Text="Update"
Width="100px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btndel" runat="server" Height="43px" Text="Delete"
Width="106px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="btndis" runat="server" CausesValidation="False"
Height="44px"
Text="Display" Width="93px" BackColor="Yellow" Font-Bold="True"
Font-Size="18px" ForeColor="#FF0066" />
&nbsp;</td>
</tr>
<tr>
<td class="style8" colspan="3"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" Font-
Bold="True"
Font-Size="30px" />
</td>
</tr>
</table>
</asp:Content>

[company.aspx] – Code View

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class company
Inherits System.Web.UI.Page
Dim con As New
SqlConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub btnins_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnins.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("insert into company values(@nm,@cty,@found)",
con)

ASP.NET Page 51
TMTBCA COLLEGE
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtcname.Text
cmd.Parameters.Add("@cty", SqlDbType.VarChar).Value = ddlcomtype.Text
cmd.Parameters.Add("@found", SqlDbType.VarChar).Value = txtfounder.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End If
MsgBox("record inserted successfully.......")
End Sub

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


Handles btnupd.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("update company set
comp_type=@cty,founder_name=@fnm where company_name=@nm", con)
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtcname.Text
cmd.Parameters.Add("@cty", SqlDbType.VarChar).Value = ddlcomtype.Text
cmd.Parameters.Add("@found", SqlDbType.VarChar).Value = txtfounder.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End If
MsgBox("record updated successfully.......")
End Sub

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


Handles btndel.Click
If Page.IsValid = True Then
Dim cmd As New SqlCommand("delete from company where
company_name=@nm", con)
cmd.Parameters.Add("@nm", SqlDbType.VarChar).Value = txtcname.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End If
MsgBox("record deleted successfully.......")
End Sub

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


Handles btndis.Click
Response.Redirect("DisplayCompany.aspx")
End Sub
End Class

[DisplayCar.aspx] – Source View

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DisplayCar.aspx.vb"


Inherits="DisplayCar" %>

ASP.NET Page 52
TMTBCA COLLEGE
<!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: 100%;
border: 4px solid #800000;
}
.style2
{
height: 80px;
text-decoration: underline;
}
.style3
{
height: 206px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

<table class="style1">
<tr>
<td align="center" class="style2"

style="font-size: 40pt; font-weight: bolder; font-style: italic; color: #800000;


background-color: #FFFF00;">
Display Of Car Details</td>
</tr>
<tr>
<td align="center" class="style3"

style="font-size: 40pt; font-weight: bolder; font-style: italic; color: #800000">


<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</td>
</tr>
<tr>
<td>
&nbsp;</td>

ASP.NET Page 53
TMTBCA COLLEGE
</tr>
</table>

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

[DisplayCar.aspx] – Code View

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class DisplayCar
Inherits System.Web.UI.Page
Dim con As New
SqlConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim cmd As New SqlCommand("select * from tbcar", con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "car")
GridView1.DataSource = ds.Tables("car")
GridView1.DataBind()
End Sub
End Class

[DisplayCompany.aspx] – Source View

<%@ Page Language="VB" AutoEventWireup="false"


CodeFile="DisplayCompany.aspx.vb" Inherits="DisplayCompany" %>

<!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: 100%;
border: 4px solid #800000;
}
.style2
{
height: 80px;

ASP.NET Page 54
TMTBCA COLLEGE
text-decoration: underline;
}
.style3
{
height: 206px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
<table class="style1">
<tr>
<td align="center" class="style2" style="font-size: 40pt; font-weight: bolder; font-
style: italic; color: #800000; background-color: #FFFF00;">
Display Of Company Details</td>
</tr>
<tr>
<td align="center" class="style3"
style="font-size: 40pt; font-weight: bolder; font-style: italic; color: #800000">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</td>
</tr>
<tr>
<td>
&nbsp;</td>
</tr>
</table>

</div>
</form>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

[DisplayCompany.aspx]- Code View

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class DisplayCompany
Inherits System.Web.UI.Page
Dim con As New
SqlConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)

ASP.NET Page 55
TMTBCA COLLEGE
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim cmd As New SqlCommand("select * from company", con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "comp")
GridView1.DataSource = ds.Tables("comp")
GridView1.DataBind()
End Sub
End Class

[Report.aspx] – Source View

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="report.aspx.vb"


Inherits="report" %>

<!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: 100%;
border: 4px solid #800000;
}
.style2
{
height: 87px;
}
.style3
{
height: 47px;
}
.style4
{
height: 52px;
}
.style5
{
height: 269px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>

ASP.NET Page 56
TMTBCA COLLEGE

<table class="style1">
<tr>
<td align="center" class="style2"

style="font-size: 40pt; font-weight: bolder; color: #FF0066; font-style: italic;


background-color: #FFFF00;">
Report</td>
</tr>
<tr>
<td align="center" class="style3"

style="font-size: xx-large; font-weight: bold; font-style: normal; color:


#FF0066">
Select Company Name
:<br />
<asp:DropDownList ID="ddlcname" runat="server" Font-Size="30px"
Height="41px"
Width="324px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="center" class="style4"

style="font-size: xx-large; font-weight: bold; font-style: normal; color:


#FF0066">
<br />
<asp:Button ID="Button1" runat="server" BackColor="Yellow" Font-
Bold="True"
Font-Size="18px" ForeColor="#FF0066" Height="42px" Text="Show"
Width="119px" />
</td>
</tr>
<tr>
<td align="center" class="style5"

style="font-size: xx-large; font-weight: bold; font-style: normal; color:


#FF0066">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</td>
</tr>
</table>

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

ASP.NET Page 57
TMTBCA COLLEGE
</html>

[report.aspx] – Code View

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration
Partial Class report
Inherits System.Web.UI.Page
Dim con As New
SqlConnection(WebConfigurationManager.ConnectionStrings("con").ConnectionString)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If Not IsPostBack Then
Dim cmd As New SqlCommand("select company_name from company", con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "report")
Dim cnt As Integer = CInt(ds.Tables("report").Rows.Count())
MsgBox("cnt=" & cnt.ToString)
'If ds.Tables().Count() > 0 Then
If ds.Tables("report").Rows.Count > 0 Then
Me.ddlcname.Items.Clear()
'If cnt > 0 Then
For i As Integer = 0 To cnt - 1
ddlcname.Items.Add(ds.Tables("report").Rows(i)(0))
Next
End If
End If

End Sub

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


Handles Button1.Click
Dim cmd As New SqlCommand("select * from company where
company_name=@cname", con)
cmd.Parameters.Add("@cname", SqlDbType.VarChar).Value =
ddlcname.SelectedValue
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "report")
GridView1.DataSource = ds.Tables("report")
GridView1.DataBind()
End Sub
End Class

ASP.NET Page 58
TMTBCA COLLEGE

ASP.NET Page 59

You might also like