Professional Documents
Culture Documents
ASP Sheet
ASP Sheet
ASP Sheet
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
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 :
ASP.NET Page 2
TMTBCA COLLEGE
c.Values.Add("BG", txtbg.Text)
Response.Cookies.Add(c)
Response.Redirect("retriveCookie.aspx")
End Sub
End Class
Imports System.Drawing
Partial Class retriveCookie
Inherits System.Web.UI.Page
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
Partial Class p2
Inherits System.Web.UI.Page
ASP.NET Page 4
TMTBCA COLLEGE
End If
End Sub
End Class
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>
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">
&nbs
p;
<asp:Button ID="btnins" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="37px" Text="Insert" Width="92px" />
<asp:Button ID="btnupd" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="32px" Text="Update" Width="96px" />
<asp:Button ID="btndel" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="35px" Text="Delete" Width="91px" />
<asp:Button ID="btndis" runat="server" BackColor="Maroon" Font-Bold="True"
Font-Size="18pt" ForeColor="White" Height="33px" Text="Display"
Width="100px" CausesValidation="False" />
<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>
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
ASP.NET Page 12
TMTBCA COLLEGE
MsgBox("Record Updated Successfully.....", MsgBoxStyle.Information)
End If
End Sub
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>
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.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">
<asp:Button ID="btnins" runat="server" BackColor="Maroon"
Font-Bold="True"
Font-Size="25px" ForeColor="White" Height="42px" Text="Insert"
Width="125px" />
<asp:Button ID="btnupd" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="25px" ForeColor="White" Height="41px" Text="Update"
Width="124px" />
<asp:Button ID="btndel" runat="server" BackColor="Maroon" Font-
Bold="True"
Font-Size="25px" ForeColor="White" Height="40px" Text="Delete"
Width="126px" />
<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
<asp:Button ID="btnreset" runat="server" BackColor="Maroon"
CausesValidation="False" Font-Bold="True" Font-Size="25px"
ForeColor="White"
Height="40px" Text="Reset" Width="118px" />
<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" />
<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 />
</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" />
</td>
</tr>
</table>
</asp:View>
</asp:MultiView>
</div>
</form>
</body>
</html>
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)
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
ASP.NET Page 25
TMTBCA COLLEGE
da.Fill(ds, "sbook")
GridView3.DataSource = ds.Tables("sbook")
Page.DataBind()
End Sub
End Sub
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>
<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.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">
</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>
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"
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" />
<asp:Button ID="btnlres" runat="server" BackColor="#CC0000"
CausesValidation="False" Font-Bold="True" Font-Size="25px"
ForeColor="White"
Height="44px" Text="Reset" Width="104px" />
<asp:LinkButton ID="lbforgot" runat="server"
CausesValidation="False"
ForeColor="#3333CC">Password Recovery</asp:LinkButton>
<asp:LinkButton ID="lbreg" runat="server" CausesValidation="False"
ForeColor="#3333CC">Registration</asp:LinkButton>
<br />
<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">
</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"> </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">
</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"> <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> 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
<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>
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)
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
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
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
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>
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">
</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 </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">
</td>
</tr>
<tr>
<td class="style10" colspan="3"
style="font-size: x-large; font-weight: bold; color: #800000">
<asp:Button ID="btnins" runat="server" Height="43px" Text="Insert"
Width="97px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
<asp:Button ID="btnupd" runat="server" Height="44px" Text="Update"
Width="100px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
<asp:Button ID="btndel" runat="server" Height="43px" Text="Delete"
Width="106px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
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>
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
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()
ASP.NET Page 48
TMTBCA COLLEGE
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">
<asp:Button ID="btnins" runat="server" Height="43px" Text="Insert"
Width="97px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
<asp:Button ID="btnupd" runat="server" Height="44px" Text="Update"
Width="100px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
<asp:Button ID="btndel" runat="server" Height="43px" Text="Delete"
Width="106px" BackColor="Yellow" Font-Bold="True" Font-Size="18px"
ForeColor="#FF0066" />
<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="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>
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
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"
ASP.NET Page 53
TMTBCA COLLEGE
</tr>
</table>
</div>
</form>
</body>
</html>
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
<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>
</td>
</tr>
</table>
</div>
</form>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
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
<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"
</div>
</form>
</body>
ASP.NET Page 57
TMTBCA COLLEGE
</html>
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
ASP.NET Page 58
TMTBCA COLLEGE
ASP.NET Page 59