0% found this document useful (0 votes)
27 views

Net Lab Programs

1. The document describes 7 VB.Net and ASP.Net application programs with the aim of creating simple forms and applications to perform tasks like checking if a number is odd or even, finding the maximum of 3 numbers, calculating the area of a circle, creating user registration and login forms, collecting job seeker details, using validation controls, and entering student information into an MS Access database. 2. The procedures describe designing forms with labels and textboxes, writing code for button click events, connecting to and inserting data into an MS Access database table, and displaying output messages. 3. The programs are executed and results are successfully verified.

Uploaded by

Arun Krish
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Net Lab Programs

1. The document describes 7 VB.Net and ASP.Net application programs with the aim of creating simple forms and applications to perform tasks like checking if a number is odd or even, finding the maximum of 3 numbers, calculating the area of a circle, creating user registration and login forms, collecting job seeker details, using validation controls, and entering student information into an MS Access database. 2. The procedures describe designing forms with labels and textboxes, writing code for button click events, connecting to and inserting data into an MS Access database table, and displaying output messages. 3. The programs are executed and results are successfully verified.

Uploaded by

Arun Krish
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1.

ODD or EVEN
Aim:
To create a VB. Net application program to check whether given number is Odd or Even.
Procedure:
Step 1: Start the Vb.Net application program in Visual Studio IDE.
Step 2: Design the form with the following controls,
• Label
• Textbox
• Button
Step 3: Change the text properties of the controls as follows,
• Label – Enter a Number
• Button – Check Odd or Even
Step 4: Write appropriate code in button click event.
Step 5: Execute the application
Step 6: Stop the application
Form Design:

Source Code:
Public Class Form1

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


Handles Button1.Click
Dim no As Integer
Dim iseven As Boolean
no = Val(TextBox1.Text)
If no Mod 2 = 0 Then
iseven = True
MsgBox(" The Number is even ")
Else
MsgBox("The Number is odd")
End If

End Sub
End Class
Output:

Result:
Thus the above mentioned program is executed and the output is verified successfully.

2. MAXIMUM OF NUMBERS

Aim:
To create a VB. Net application program to find maximum of given three numbers.
Procedure:
Step 1: Start the Vb.Net application program in Visual Studio IDE.
Step 2: Design the form with the following controls,
• Label (3)
• Textbox(3)
• Button
Step 3: Change the text properties of the controls as follows,
• Label1 – Enter First Number
• Label2 – Enter Second Number
• Label3 – Enter Third Number
• Button – Find Maximum
Step 4: Write appropriate code in button click event.
Step 5: Execute the application
Step 6: Stop the application
Form Design:
Source Code:
Public Class Form1

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


Handles Button1.Click
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
If (a > b And a > c) Then
MsgBox(" First Number is Greater")
ElseIf (b > a And b > c) Then
MsgBox(" Second Number is Greater")
Else
MsgBox(" Third Number is Greater")
End If
End Sub
End Class
Output:

Result:
Thus the above mentioned program is executed and the output is verified successfully.

3. AREA OF A CIRCLE
Aim:
To create a VB. Net application program to find area of a circle.
Procedure:
Step 1: Start the Vb.Net application program in Visual Studio IDE.
Step 2: Design the form with the following controls,
• Label (2)
• Textbox (2)
• Button
Step 3: Change the text properties of the controls as follows,
• Label1 – Enter the Radius Of a Circle
• Label2- Area
• Button – Find Area
Step 4: Change the following control properties:
Label 2 – Visible – False
Textbox 2 – visible – False
Step 5: Write appropriate code in button click event.
Step 6: Execute the application
Step 7: Stop the application
Form Design:

Source Code:
Public Class Form1

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


Handles Button1.Click
Dim radius As Integer
Dim area As Single
radius = Val(TextBox1.Text)
area = 3.14 * radius * radius
Label2.Visible = True
TextBox2.Visible = True
TextBox2.Text = area

End Sub
End Class

OUTPUT:

Result:
Thus the above mentioned program is executed and the output is verified successfully.
4. USER REGISTRATION FORM
Aim:
To create a ASP.NET web form to create a user registration form.
Procedure:
Step 1: Start the ASP.Net application program in Visual Studio IDE by clicking file--> new--> website
-->asp.net empty website.
Step 2: Add three forms for Login, New user registration and destination page.
Step 3: Design the Login page form with login control and change the following properties:
CreateUserText – New user
CreateUserconUrl - ~/newuser.aspx
CreateUSerUrl - ~/newuser.aspx
DestinationPageUrl - ~/home.aspx
Step 4: Design the new user page form with createuserwizard control and change the following
properties:
continueDestinationPgeUrl - ~/login.aspx
Step 5: Execute the application
Step 7: Stop the application
Form Design:
Login.aspx:

NewUser.aspx:
Home Page:

OUTPUT:
Result:
Thus the above mentioned program is executed and the output is verified successfully.

5. JOB SEEKERS DETAIL


Aim:
To create a ASP.NET web form to enter job seekers details.
Procedure:
Step 1: Start the ASP.Net application program in Visual Studio IDE by clicking file--> new--> website
-->asp.net empty website.
Step 2: Add new form
Step 3: Design the form with necessary controls.
Step 4: Change the necessary text properties of the controls.
Step 5: Write appropriate code in button click event.
Step 6: Execute the application
Step 7: Stop the application
Form Design:
Default1.aspx:
Default2.aspx:

Source Code:
Default1.aspx:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Session["A"] = TextBox1.Text;
Session["B"] = TextBox2.Text;
if (RadioButton1.Checked == true)
{
Session["C"] = RadioButton1.Text;
}
else
{
Session["C"] = RadioButton2.Text;
}
Session["D"] = DropDownList1.SelectedItem;
Session["E"] = TextBox3.Text;
Session["F"] = TextBox4.Text;
Session["G"] = TextBox5.Text;
Response.Redirect("Default2.aspx");

}
}

Default2.aspx:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

Label1.Text = "YOUR NAME IS " + Session["A"].ToString();


Label2.Text = "YOUR AGE IS "+Session["B"].ToString();
Label3.Text = "YOUR GENDER IS "+Session["C"].ToString();
Label4.Text = "YOUR QUALIFICATION IS " + Session["D"].ToString();
Label5.Text = "YOUR EMAIL ID IS " + Session["E"].ToString();
Label6.Text = "YOUR PHONE NUMBER IS " + Session["F"].ToString();
Label7.Text = "YOUR ADDRESS IS " + Session["G"].ToString();
}
}

OUTPUT:

Result:
Thus the above mentioned program is executed and the output is verified successfully.

6. VALIDATION CONTROL
Aim:
To create a ASP.NET web form to create a user registration form.
Procedure:
Step 1: Start the ASP.Net application program in Visual Studio IDE by clicking file--> new--> website
-->asp.net empty website.
Step 2: Add Label and textbox and change their text properties.
Step 3: Add validation Controls and edit the following properties:
i) RequiredFieldValidator:
• Control To Validate
• Error Message
ii) RangeValidator:
• Control To Validate
• Error Message
• Maximum Value
• Minimum Value
iii) Compare Validator:
• Control To Validate
• Error Message
• Control to Compare
iv) Regular ExpressionVaidator:
• Control To Validate
• Error Message
• Validation Expresion

Step 4: Execute the application


Step 5: Stop the application
Form Design:

OUTPUT:

Result:
Thus the above mentioned program is executed and the output is verified successfully.
7. STUDENT INFORMATION

Aim:
To create a ASP.NET web form to enter student information using MS Access Database.
Procedure:
Step 1: Start the ASP.Net application program in Visual Studio IDE by clicking file--> new--> website
-->asp.net empty website.
Step 2: Add new form
Step 3: Design the form with necessary controls.
Step 4: Change the necessary text properties of the controls.
Step 5: Write appropriate code in button click event.
Step 6: Create a table in MS Access Database.
Step 7: Connect the database to the created form
Step 6: Execute the application
Step 7: Stop the application
Form Design:

Table Design:

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
OleDbCommand com;
OleDbConnection con;
OleDbDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\Users\\SAHANA\\Desktop\\db.mdb");
}
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
com = new OleDbCommand("insert into student values('" + TextBox1.Text + "','" +
TextBox2.Text + "','" + TextBox3.Text + "')", con);
com.ExecuteNonQuery();
con.Close();
Label4.Visible = true;
Label4.Text = "Inserted Succesfully";
}
protected void Button2_Click(object sender, EventArgs e)
{
con.Open();
com = new OleDbCommand("delete from student where regno='" + TextBox1.Text + "'", con);
com.ExecuteNonQuery();
con.Close();
Label4.Visible = true;
Label4.Text = "Deleted Succesfully";
}
protected void Button3_Click(object sender, EventArgs e)
{
con.Open();
com = new OleDbCommand("update student set sname='" + TextBox2.Text + "',dept='" +
TextBox3.Text + "' where regno='"+TextBox1.Text+"'", con);
com.ExecuteNonQuery();
con.Close();
Label4.Visible = true;
Label4.Text = "Updated Succesfully";
}
protected void Button4_Click(object sender, EventArgs e)
{
con.Open();
com = new OleDbCommand("select * from student where regno='" + TextBox1.Text + "'",
con);
dr = com.ExecuteReader();
if (dr.Read())
{
TextBox2.Text = dr[1].ToString();
TextBox3.Text = dr[2].ToString();
}
else
{
Label4.Text = "Not Found";
}

con.Close();
}
protected void Button5_Click(object sender, EventArgs e)
{
TextBox1.Text = " ";
TextBox2.Text = " ";
TextBox3.Text = " ";
}
}
Output:

Result:
Thus the above mentioned program is executed and the output is verified successfully.
8. GRIDVIEW CONTROL

Aim:
To create a ASP.NET web application to enter student information using MS Access Database and
gridview control.
Procedure:
Step 1: Start the ASP.Net application program in Visual Studio IDE by clicking file--> new--> website
-->asp.net empty website.
Step 2: Add new form
Step 3: Design the form with necessary controls.
Step 4: Change the necessary text properties of the controls.
Step 5: Write appropriate code in button click event.
Step 6: Create a table in MS Access Database.
Step 7: Connect the database to the created form
Step 6: Execute the application
Step 7: Stop the application
Form Design:

Table Design:

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;

public partial class _Default : System.Web.UI.Page


{
DataSet ds = new DataSet();
OleDbDataAdapter ad;
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\\db.mdb");
protected void Page_Load(object sender, EventArgs e)
{
GridView1.AllowPaging = true;
GridView1.AllowSorting = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
ad = new OleDbDataAdapter("select * from sinfo", con);
ad.Fill(ds, "0");
GridView1.DataSource = ds.Tables["0"];
GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
ad = new OleDbDataAdapter("insert into sinfo values('" + TextBox1.Text + "','" +
TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "')", con);
ad.Fill(ds, "0");
GridView1.DataSource=ds.Tables["0"];
GridView1.DataBind();
Label5.Text = "RECORD INSERTED";

}
protected void Button3_Click(object sender, EventArgs e)
{
ad = new OleDbDataAdapter("delete from sinfo where rno='" + TextBox1.Text + "'", con);
ad.Fill(ds, "0");
GridView1.DataSource=ds.Tables["0"];
GridView1.DataBind();
Label5.Text = "RECORD DELETED";
}
}

Output:

Result:
Thus the above mentioned program is executed and the output is verified successfully.

You might also like