SHREE UTTAR GUJARAT BCA COLLEGE
NAME :- GAJERA HET N. CLASS:- TYBCA
ROLL NO :- 81 SUBJECT :- ASP.NET
INDEX
Page
No. Program Name No Sign
1 Design a Registration form Default.aspx page with fields Username,
choose password, confirm password, age, email id, mobileno and a
submit button.
Use:
a) RequiredFieldValidator - for Username
b) CompareValidator - for Confirm password field.
c) RangeValidator - for Age field. d)
d) RegularExpressionValidator - for Email field.
e) CustomValidator - for mobile no field.
2 Write a program to perform to design a simple calculator to perform
addition, subtraction, multiplication and division.
3 Design a user interface to print the result student with total marks and
percentage.
4 Write a program Day of the Date.
5
Create a Database “DbStudent”. Create following table. tbl_student
(stud_id, stud_rollno, stud_name, stud_class, stud_department)
• Write a simple program to demonstrate Insertion of data into
database.
• Write a program to show recodes in GridView Control.
• Write a program to print the Student Name and Student Class
based on the Student Department (Search Functionality).
• Write a program to update student record.
• Write a program to delete particular student record.
1. Design a Registration form Default.aspx page with fields Username, choose password,
confirm password, age, email id, mobileno and a submit button.
ASP.NET
Use:
f) RequiredFieldValidator - for Username
g) CompareValidator - for Confirm password field.
h) RangeValidator - for Age field. d)
i) RegularExpressionValidator - for Email field.
j) CustomValidator - for mobile no field.
Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="validationEx.aspx.vb"
Inherits="validationEx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style
type="text/css">
.auto-style1 {
width: 62%;
}
.auto-style2 {
width: 124px;
}
.auto-style3 {
width: 21px;
}
.auto-style5 {
width: 124px;
height: 42px;
}
.auto-style6 {
width: 21px;
height: 42px;
}
.auto-style7 {
width: 140px;
}
.auto-style8 {
width: 140px;
height: 42px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td colspan="4" style="text-align: center">Registration Form</td>
</tr>
<tr>
<td class="auto-style2">Name</td>
<td class="auto-style3">:</td>
<td class="auto-style7">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
Page 1
ASP.NET
</td>
<td class="auto-style5">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1" ErrorMessage="Please Enter
Name"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Email</td>
<td class="auto-style3">:</td>
<td class="auto-style7">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
<td class="auto-style5">
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox3"
ErrorMessage="Please Enter Email Properly"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Password</td>
<td class="auto-style3">:</td>
<td class="auto-style7">
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
<td class="auto-style5"> </td>
</tr>
<tr>
<td class="auto-style5">Confirm Password</td>
<td class="auto-style6">:</td>
<td class="auto-style8">
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
<td class="auto-style5">
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox4" ControlToValidate="TextBox5" ErrorMessage="Password
and
Confirm Password must be same"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Age</td>
<td class="auto-style3">:</td>
<td class="auto-style7">
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
</td>
<td class="auto-style5">
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox6" ErrorMessage="Age must Be 20 - 40."
MaximumValue="40"
MinimumValue="20"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Mobile No</td>
Page 2
ASP.NET
<td class="auto-style3">:</td>
<td class="auto-style7">
<asp:TextBox ID="TextBox7" runat="server"
TextMode="Number"></asp:TextBox>
</td>
<td class="auto-style5">
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="TextBox7" ErrorMessage="Enter only 10 digit mobile number"
SetFocusOnError="True"></asp:CustomValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
</td>
<td class="auto-style3">
<asp:Button ID="Button1" runat="server" Text="Register" />
</td>
<td class="auto-style7"> </td>
<td class="auto-style5"> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
Page 3
ASP.NET
2. Write a program to perform to design a simple calculator to perform addition, subtraction,
multiplication and division.
Default.aspsx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnAdd_Click(sender As Object, e As EventArgs) Handles
btnAdd.Click
Dim Sum As Integer
Dim a As Integer
Dim b As Integer a
= Val(TextBox1.Text)
b = Val(TextBox2.Text)
Sum = (a + b)
TextBox3.Text = Sum
End Sub
Protected Sub btnSubtract_Click(sender As Object, e As EventArgs) Handles
btnSubtract.Click
Dim subno As Integer
Dim a,b As Integer a
= Val(TextBox1.Text)
b = Val(TextBox2.Text)
subno = (a - b)
TextBox3.Text() = subno
End Sub
Protected Sub btnDivide_Click(sender As Object, e As EventArgs) Handles
btnDivide.Click
Dim divno As
Integer Dim a,b As
Integer a =
Val(TextBox1.Text)
b = Val(TextBox2.Text)
divno = (a / b)
TextBox3.Text = divno
End Sub
Protected Sub btnMultiply_Click(sender As Object, e As EventArgs)
Handles btnMultiply.Click Dim mul As Integer
Dim a As Integer
Dim b As Integer a
= Val(TextBox1.Text)
b = Val(TextBox2.Text)
mul = (a * b)
TextBox3.Text = mul
End Sub
Page 4
ASP.NET
End Class
Page 5
ASP.NET
3. Design a user interface to print the result student with total marks and percentage.
Subject 1
Subject 2
Subject 3
Total Marks
Percantage Calculate
Clear
Division
Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:Label ID="Label1" runat="server" Font-Size="20pt"
Text="Q-2 Markes in percentage calculate"></asp:Label>
<br />
<br />
<br />
<br /> SUBJECT
1 :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br /> SUBJECT
2 :
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br /> SUBJECT
3 :
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="total" runat="server" Height="40px"
Text="Calculate" Width="80px" />
<asp:Button ID="btnClear" runat="server" Height="40px"
Text="CLEAR" Width="80px" />
Page 6
ASP.NET
<asp:Button ID="btnExit" runat="server" Height="40px"
Text="Exit" Width="80px" />
<br />
<br /> TOTAL OF
MARKS : <asp:TextBox
ID="TextBox4"
runat="server"></asp:TextBox>
<br /> <br /> PERCENTAGE :
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</div>
</center>
</form>
</body>
</html>
Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub total_Click(sender As Object, e As EventArgs) Handles
total.Click
Dim Sum As Integer
Dim a As Integer
Dim b As Integer
Dim c As Integer a
= Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
Sum = (a + b + c) / 3
TextBox4.Text = a + b + c
TextBox5.Text= Sum
End Sub
Protected Sub btnClear_Click(sender As Object, e As EventArgs) Handles
btnClear.Click
TextBox1.Text = String.Empty
TextBox2.Text = String.Empty
TextBox3.Text = String.Empty
TextBox4.Text = String.Empty
TextBox5.Text = String.Empty
End Sub
Protected Sub btnExit_Click(sender As Object, e As EventArgs) Handles
btnExit.Click System.Environment.Exit(0)
End Sub
End Class
Output
Page 7
ASP.NET
Page 8
ASP.NET
4. Write a program Day of the Date.
Default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles
btnDisplay.Click
Dim dateValue As Date
dateValue = TextBox1.Text
TextBox2.Text =WeekdayName(Weekday(DateValue))
End Sub
End Class
Output
Page 9
ASP.NET
5. Create a Database “DbStudent”. Create following table. tbl_student (stud_id, stud_rollno,
stud_name, stud_class, stud_department)
• Write a simple program to demonstrate Insertion of data into database.
• Write a program to show recodes in GridView Control.
• Write a program to print the Student Name and Student Class based on the Student
Department (Search Functionality).
• Write a program to update student record.
• Write a program to delete particular student record.
Default.aspx
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE
html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Student id:<asp:TextBox ID="txtid"
runat="server"></asp:TextBox>
<br />
<br />
student name:<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
 
;
<br /><br />
student class<asp:TextBox ID="txtclass"
runat="server"></asp:TextBox>
<br /><br /><br /><br /><br />
<asp:GridView ID="GridView1"
runat="server">
</asp:GridView>
<br /><br />
<asp:Button ID="btninsert" runat="server" Text="insert"
/> &nb sp;
<asp:Button ID="btnupdate" runat="server" Text="update"
/> &nb
sp;
<asp:Button ID="btndelete" runat="server" Text="delete"
/>
</div>
Page 10
ASP.NET
</form>
</body>
</html>
Deafult.aspx.vb
Imports System.Data.SqlClient
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Dim con As New SqlConnection("DataSource=(LocalDB)\
v11.0;AttachDbFilename= D:\asp assignment\8\App_Data\Database.mdf;Integrated
Security=True")
Protected Sub btninsert_Click(sender As Object, e As EventArgs)
Handles btninsert.Click
Dim sid As Integer = txtid.Text Dim sname
As String = txtname.Text
Dim sclass As String = txtclass.Text con.Open()
Dim command As New SqlCommand("insert into stud values('" & sid &
"','"
& sname & "','" & sclass & "')", con)
command.ExecuteNonQuery()
MsgBox("record inserted")
con.Close()
list()
End Sub
Private Sub list()
Dim command As New SqlCommand("select * from stud", con)
Dim sd As New SqlDataAdapter(command) Dim dt As
New DataTable
sd.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
Protected Sub btnupdate_Click(sender As Object, e As EventArgs)
Handles btnupdate.Click
Dim sid As Integer = txtid.Text Dim sname
As String = txtname.Text
Dim sclass As String = txtclass.Text con.Open()
Dim command As New SqlCommand("update stud set id='" & sid &
"',class='"
& sclass & "' where name='" & sname & "'",
con) command.ExecuteNonQuery()
MsgBox("update suceesfully")
con.Close() list()
End Sub
Page 11
ASP.NET
Protected Sub btndelete_Click(sender As Object, e As EventArgs)
Handles btndelete.Click
Dim sid As Integer = txtid.Text
con.Open()
Dim command As New SqlCommand("delete stud where id='" & sid &
"'", con) command.ExecuteNonQuery() MsgBox("record deleted")
con.Close() list()
End Sub
Protected Sub Page_Load(ByVal sender As
Object, ByVal e As System.EventArgs) Handles Me.Load
list() list()
End Sub
End class
Output
Page 12