VEER NARMAD SOUTH GUJARAT UNIVERSITY, SURAT.
Third Year
Bachelor of Computer Application (T.Y.B.C.A.)
Semester - V
Vimal Tormal Poddar BCA College
Pandesara, Surat.
File Submission
506: Practical of ASP.NET
YEAR: 2022-23
Submitted by
Roll No : 45
Name : Harsh J. Mendapara
Submitted To
Prof. Prashant Ghantiwala
VIMAL TORMAL PODDAR BCA COLLEGE
BACHELOR
OF
COMPUTER APPLICATION
B.C.A
Certificate
This is to certify that Mr. / Ms. Harsh J Mendpaara Seat
no.2020028970 has satisfactorily completed his / her software computer
Practical Work in PAPER No. 505-ASP.NET for the SEMESTER- 5 during
the academic year 2022-2023.
Date :_05/09/2022 _________________
Teacher-In-Charge
INDEX
Page
Sr. Date Query No. Sign.
No
Q1 05-09-2022 Develop a web page that 1
accept two numbers (Using To
Textbox) and make sum of 1
those numbers and print on
textbox.
Q2 05-09-2022 Develop a web page that 2
accept two numbers (Using To
Textbox) and make 2
Subtraction of those numbers
and print on textbox.
Q3 05-09-2022 Develop a web page that 3
accept two numbers (Using To
Textbox) and make 3
Division of those numbers
and print on textbox
Q4 05-09-2022 Develop a web page that 4
accept two numbers (Using To
Textbox) and make 4
Multiplication of those
numbers and print on textbox.
Q5 05-09-2022 Develop a User Registration 5
web page with appropriate To
fields and save the record in 7
database table. (Take
Appropriate database and
table fields)
Q6 05-09-2022 Develop a User Login
web page with Login 8
Control and check user To
name and password 9
with database table.
(Show appropriate msg
to user if user name or
password are invalid)
Q7 05-09-2022 Develop a web page that 10
accept students details To
(Student ID, Student Name, 13
Area, Mobile, Email,
Standard) and save in
database record. Show
students records on
GridView control and also
perform Update and Delete
operation
505-ASP.NET
1. Develop a web page that accept two numbers (Using Textbox) and make sum
of those numbers and print on textbox.
Public Class Que1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
End Sub
Private Sub submit_Click(sender As Object, e As EventArgs)
Handles submit.Click
val3.Text = Val(val1.Text) + Val(val2.Text)
End Sub
End Class
45-Harsh Mendapara Page 1
505-ASP.NET
2. Develop a web page that accept two numbers (Using Textbox) and make
Subtraction of those numbers and print on textbox.
Public Class Que2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
End Sub
Private Sub submit_Click(sender As Object, e As EventArgs)
Handles submit.Click
val3.Text = Val(val1.Text) - Val(val2.Text)
End Sub
End Class
45-Harsh Mendapara Page 2
505-ASP.NET
3. Develop a web page that accept two numbers (Using Textbox) and make
Division of those numbers and print on textbox.
Public Class Que3
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
End Sub
Private Sub submit_Click(sender As Object, e As EventArgs)
Handles submit.Click
val3.Text = Val(val1.Text) / Val(val2.Text)
End Sub
End Class
45-Harsh Mendapara Page 3
505-ASP.NET
4. Develop a web page that accept two numbers (Using Textbox) and make
Multiplication of those numbers and print on textbox.
Public Class Que4
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
End Sub
Private Sub submit_Click(sender As Object, e As EventArgs)
Handles submit.Click
val3.Text = Val(val1.Text) * Val(val2.Text)
End Sub
End Class
45-Harsh Mendapara Page 4
505-ASP.NET
5. Develop a User Registration web page with appropriate fields and save the
record in database table. (Take Appropriate database and table fields)
Imports System.Configuration
Imports MySql.Data.MySqlClient
Public Class Que5
Inherits System.Web.UI.Page
Dim con As New
MySqlConnection("DataSource=127.0.0.1;Database=student_form;UserID
=root;Password=root")
Dim str As String
Dim str2 As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
con.Open()
str2 = "select * from student_data values"
End Sub
Private Sub Submit_Click(sender As Object, e As EventArgs)
Handles Submit.Click
If (password1.Text <> password2.Text) Then
MsgBox("password is mismatch")
45-Harsh Mendapara Page 5
505-ASP.NET
Else
Try
Dim cmd As New MySqlCommand
'insert into table value
str = "insert into user_info_data values('" &
user_id.Text & "',
'" &
f_name.Text & "',
'" &
l_name.Text & "',
'" &
email.Text & "',
'" &
mobile.Text & "',
'" &
city.Text & "',
'" &
gender.Text & "',
'" &
u_name.Text & "',
'" &
password1.Text & "')"
'str = "insert into stude"
cmd.CommandText = str
cmd.Connection = con
'MsgBox("Record Saves Successfully")
'Console.WriteLine("hey ")
cmd.ExecuteNonQuery()
cmd.Dispose()
MsgBox("Value accepted")
clearform()
Catch ex As Exception
MsgBox("You Entered Invalid Data")
End Try
End If
End Sub
Private Sub clearform()
45-Harsh Mendapara Page 6
505-ASP.NET
user_id.Text = String.Empty
f_name.Text = String.Empty
l_name.Text = String.Empty
email.Text = String.Empty
mobile.Text = String.Empty
city.Text = String.Empty
gender.Text = String.Empty
u_name.Text = String.Empty
password1.Text = String.Empty
password2.Text = String.Empty
End Sub
End Class
45-Harsh Mendapara Page 7
505-ASP.NET
6. Develop a User Login web page with Login Control and check user name and
password with database table. (Show appropriate msg to user if user name or
password are invalid)
Imports System.Configuration
Imports MySql.Data.MySqlClient
Public Class Que6
Inherits System.Web.UI.Page
Dim con As New
MySqlConnection("DataSource=127.0.0.1;Database=student_form;UserID
=root;Password=root")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
con.Open()
End Sub
Private Sub submit_Click(sender As Object, e As EventArgs)
Handles submit.Click
Dim cmd As New MySqlCommand("select * from user_info_data
where UserName =@username and Password=@password", con)
cmd.Parameters.AddWithValue("@username", u_name.Text)
cmd.Parameters.AddWithValue("@password", pass1.Text)
Dim da As New MySqlDataAdapter(cmd)
Dim dt As New DataTable()
45-Harsh Mendapara Page 8
505-ASP.NET
da.Fill(dt)
If dt.Rows.Count > 0 Then
'Response.Redirect("Details.aspx")
MsgBox("welcome")
clearform()
Else
ClientScript.RegisterStartupScript(Page.[GetType](),
"validation", "<script language='javascript'>alert('Invalid
Username and Password')</script>")
End If
End Sub
Private Sub clearform()
u_name.Text = String.Empty
pass1.Text = String.Empty
End Sub
End Class
45-Harsh Mendapara Page 9
505-ASP.NET
7. Develop a web page that accept students details (Student ID, Student Name,
Area, Mobile, Email, Standard) and save in database record. Show students
records on GridView control and also perform Update and Delete operation.
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
'Dim con As New
MySqlConnection("DataSource=127.0.0.1;Database=student_form;UserID=root;Password=root
")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindGrid()
End If
End Sub
Private Sub BindGrid()
Dim constr As String = ConfigurationManager.ConnectionStrings("Data
Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename='E:\personal projects\ASP.NET\505-
ASP.NET
45-Harsh Mendapara Page 10
505-ASP.NET
assignment\WebApplication2\WebApplication2\App_Data\student_data.mdf';Integrated
Security=True").ConnectionString
Dim query As String = "SELECT * FROM Customers"
Using con As SqlConnection = New SqlConnection(constr)
Using sda As SqlDataAdapter = New SqlDataAdapter(query, con)
Using dt As DataTable = New DataTable()
sda.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
End Using
End Using
End Using
End Sub
Protected Sub Insert(ByVal sender As Object, ByVal e As EventArgs)
Dim name As String = txtName.Text
Dim country As String = txtCountry.Text
Dim query As String = "INSERT INTO Customers VALUES(@Name, @Country)"
Dim constr As String =
ConfigurationManager.ConnectionStrings("constr").ConnectionString
txtName.Text = ""
txtCountry.Text = ""
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand(query)
cmd.Parameters.AddWithValue("@Name", name)
cmd.Parameters.AddWithValue("@Country", country)
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
Me.BindGrid()
End Sub
Protected Sub OnRowEditing(sender As Object, e As GridViewEditEventArgs)
GridView1.EditIndex = e.NewEditIndex
Me.BindGrid()
45-Harsh Mendapara Page 11
505-ASP.NET
End Sub
Protected Sub OnRowUpdating(ByVal sender As Object, ByVal e As
GridViewUpdateEventArgs)
Dim row As GridViewRow = GridView1.Rows(e.RowIndex)
Dim customerId As Integer = Convert.ToInt32(GridView1.DataKeys(e.RowIndex).Values(0))
Dim name As String = (TryCast(row.FindControl("txtName"), TextBox)).Text
Dim country As String = (TryCast(row.FindControl("txtCountry"), TextBox)).Text
Dim query As String = "UPDATE Customers SET Name=@Name, Country=@Country WHERE
CustomerId=@CustomerId"
Dim constr As String =
ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand(query)
cmd.Parameters.AddWithValue("@CustomerId", customerId)
cmd.Parameters.AddWithValue("@Name", name)
cmd.Parameters.AddWithValue("@Country", country)
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
GridView1.EditIndex = -1
Me.BindGrid()
End Sub
Protected Sub OnRowCancelingEdit(sender As Object, e As EventArgs)
GridView1.EditIndex = -1
Me.BindGrid()
End Sub
Protected Sub OnRowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs)
Dim customerId As Integer = Convert.ToInt32(GridView1.DataKeys(e.RowIndex).Values(0))
Dim query As String = "DELETE FROM Customers WHERE CustomerId=@CustomerId"
Dim constr As String =
ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand(query)
45-Harsh Mendapara Page 12
505-ASP.NET
cmd.Parameters.AddWithValue("@CustomerId", customerId)
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
Me.BindGrid()
End Sub
Protected Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow AndAlso e.Row.RowIndex <>
GridView1.EditIndex Then
TryCast(e.Row.Cells(2).Controls(2), LinkButton).Attributes("onclick") = "return
confirm('Do you want to delete this row?');"
End If
End Sub
Protected Sub OnPaging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
GridView1.PageIndex = e.NewPageIndex
Me.BindGrid()
End Sub
End Class
45-Harsh Mendapara Page 13