Net Lab Programs
Net Lab Programs
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
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
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
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.
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;
}
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;
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
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;
}
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.