0% found this document useful (0 votes)
51 views43 pages

Net Record

The document contains code for a student mark sheet program that allows users to insert and update student records in a database table using text boxes and buttons. It opens a SQL connection and defines commands to insert a new record into the table with values from the text boxes when the insert button is clicked. It also defines a command to update an existing record matching the ID field with the new text box values when the update button is clicked. The label and gridview are then updated on successful queries.

Uploaded by

suganthi s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views43 pages

Net Record

The document contains code for a student mark sheet program that allows users to insert and update student records in a database table using text boxes and buttons. It opens a SQL connection and defines commands to insert a new record into the table with values from the text boxes when the insert button is clicked. It also defines a command to update an existing record matching the ID field with the new text box values when the update button is clicked. The label and gridview are then updated on successful queries.

Uploaded by

suganthi s
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Arithmetic Operations.

Program:

Public Class _Default


Inherits System.Web.UI.Page
Dim a, b, c As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Load
End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
a = TextBox1.Text
b = TextBox2.Text
c=a+b
TextBox3.Text = c
End Sub

Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
a = TextBox1.Text
b = TextBox2.Text
c=a-b
TextBox3.Text = c
End Sub

Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles


Button3.Click
a = TextBox1.Text
b = TextBox2.Text
c=a*b
TextBox3.Text = c
End Sub

Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles


Button4.Click
a = TextBox1.Text
b = TextBox2.Text
c=a/b
TextBox3.Text = c
End Sub
Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
MsgBox("Deleted")
End Sub
End Class
Output:
File Upload Control

Program:

Public Class _Default


Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


Handles Me.Load

End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
If (FileUpload1.HasFile) Then
FileUpload1.SaveAs(Server.MapPath("~/") + FileUpload1.FileName)
Image1.ImageUrl = "~/" + FileUpload1.FileName
Label1.Text = "Image Upload Successfully!"
Else
Label1.Text = "Select Image first!"
End If
End Sub
End Class
Output:
Drop down List and List box

Program:

Public Class _Default


Inherits System.Web.UI.Page
Dim I, S As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Load
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
S = InputBox("Enter the Number of Elements")
For I = 0 To S
DropDownList1.Items.Add(InputBox("Enter the elements"))
Next
End Sub

Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
DropDownList1.Items.Remove(DropDownList1.SelectedItem)
End Sub

Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles


Button3.Click
ListBox1.Items.Add(DropDownList1.SelectedItem)
DropDownList1.Items.Remove(DropDownList1.SelectedItem)
End Sub

Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles


Button4.Click
DropDownList1.Items.Clear()
End Sub

Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles


Button5.Click
S = InputBox("Enter the Number of Elements")
For I = 0 To S
ListBox1.Items.Add(InputBox("Enter the elements"))
Next
End Sub
Protected Sub Button6_Click(sender As Object, e As EventArgs) Handles
Button6.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub

Protected Sub Button7_Click(sender As Object, e As EventArgs) Handles


Button7.Click
DropDownList1.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
Protected Sub Button8_Click(sender As Object, e As EventArgs) Handles
Button8.Click
ListBox1.Items.Clear()
End Sub
End Class
Output:
Ad Rotator Control

Program:

<?xml version="1.0" encoding="utf-8" ?>


<Advertisements>
<Ad>
<ImageUrl>~/img/1.jpg</ImageUrl>
<NavigateUrl>https://www.javatpoint.com/vb-net-dot-net-framework-
introduction</NavigateUrl>
</Ad>

<Ad>
<ImageUrl>~/img/2.jpg</ImageUrl>

<NavigateUrl>https://www.tutorialspoint.com/asp.net/asp.net_ad_rotator.h
tm</NavigateUrl>
</Ad>
</Advertisements>
Output:
Calendar Control

Program:

Public Class _Default


Inherits Page
Dim DD1 As DateTimeOffset

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


Handles Me.Load

End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button.Click
lblday.Text = Calendar1.TodaysDate.ToShortDateString()
Response.Write("<BR>MONTH :" +
Calendar1.SelectedDate.Month.ToString)
Response.Write("<BR>YEAR :" + Calendar1.SelectedDate.Year.ToString)
Response.Write("<BR>DAY OF YEAR :" +
Calendar1.SelectedDate.DayOfYear.ToString)
Response.Write("<BR>DAY OF WEEK :" +
Calendar1.SelectedDate.DayOfWeek.ToString)
End Sub
Protected Sub Calendar1_DayRender(sender As Object, e As
DayRenderEventArgs) Handles Calendar1.DayRender
If (e.Day.Date.DayOfWeek = DayOfWeek.Sunday) Then
e.Cell.BackColor = System.Drawing.Color.Yellow
e.Cell.ForeColor = System.Drawing.Color.Green
End If
End Sub
End Class
Source code:

<%@ Page Title="Home Page" Language="VB"


MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Default.aspx.vb" Inherits="EXNO5._Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent"


runat="server">

<p>
<br />
</p>
<p>

<asp:Calendar ID="Calendar1" runat="server" BackColor="Aqua"


BorderColor="#0066FF" BorderStyle="Double" Enabled="False"
ForeColor="Black" Height="220px" Width="351px">
<DayHeaderStyle BackColor="#FF66FF" />
<DayStyle BackColor="#FFCCFF" />
<OtherMonthDayStyle BackColor="Blue" BorderColor="Black"
BorderStyle="Groove" ForeColor="Black" />
<SelectedDayStyle BackColor="Red" />
<TitleStyle BackColor="Yellow" />
<TodayDayStyle BackColor="#66FF33" BorderColor="Black"
Font-Bold="True" BorderStyle="Solid" />
<WeekendDayStyle BackColor="Red" BorderColor="Black" />
</asp:Calendar>
<p>
<asp:Button ID="Button" runat="server" Text="ok" />
</p>
<p>
Today’s date is:
<asp:Label ID="lblday" runat="server"></asp:Label>
</p>
</asp:Content>
Output:
Validation Controls

Public Class WebForm1


Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Me.Load

End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
MsgBox("Submitted Successfully")
End Sub

Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
End Sub
End Class
Output:
Binding Data in Grid View

Connectivity:
Output:
Login Page using User Control

Public Class _Default


Inherits Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


Handles Me.Load

End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
MsgBox("LOGIN SUCCESSFUL")
End Sub

Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
MsgBox("CLEARED")
End Sub
End Class
Output:
Registration Page using Session Variable

USER CONTROL.aspx.vb:

Public Class USER_CONTROL


Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Me.Load

End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
Session("USERNAME") = TextBox1.Text
Session("PHONE") = TextBox2.Text
Session("AGE") = TextBox3.Text
Session("E-MAIL") = TextBox4.Text
Response.Redirect("details.aspx")
End Sub

Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End Sub
End Class

DETAILS.aspx.vb:

Public Class details


Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Me.Load

Label1.Text = Session("USERNAME")
Label2.Text = Session("PHONE")
Label3.Text = Session("AGE")
Label4.Text = Session("E-MAIL")
End Sub

End Class
Output:
Student Mark sheet

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

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


{
SqlConnection con = new SqlConnection(@"Data
Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Administrator\Docu
ments\Visual Studio
2013\WebSites\WebSite3\App_Data\Database.mdf;Integrated
Security=True");
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("insert into aaa values('" +
TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" +
TextBox4.Text + "','" + TextBox5.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();
Label1.Text="Data has been inserted";
GridView1.DataBind();
TextBox1.Text= "";
TextBox2.Text= "";
TextBox3.Text= "";
TextBox4.Text = "";
TextBox5.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("update aaa set name='" +
TextBox2.Text + "',dept='" + TextBox3.Text + "',m1='" + TextBox4.Text +
"',m2='" + TextBox5.Text + "' where Id='" + TextBox1.Text + "'", con);
cmd.ExecuteNonQuery();
con.Close();
Label1.Text = "Data has been updated";
GridView1.DataBind();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
}
protected void Button3_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("delete from aaa where
Id='"+Convert.ToInt32(TextBox1.Text).ToString()+"'",con);
cmd.ExecuteNonQuery();
con.Close();
Label1.Text = "Data has been deleted";
GridView1.DataBind();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
}
}
Output:
Insert Update Delete View using Source

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using
system.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace insert_update_delete
{
public partial class WebForm1 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data
Source=(LocalDB)\v11.0;AttachDbFilename=c:\users\system103\document
s\visual studio 2013\Projects\insert update delete\insert update
delete\App_Data\Database1.mdf;Integrated Security=True");

protected void Page_Load(object sender, EventArgs e)


{
con.Open();
}

protected void Button1_Click(object sender, EventArgs e)


{
SqlCommand cmd = new SqlCommand("insert into std values('" +
TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('Data has been Inserted')</script>");
GridView1.DataBind();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("update std set name='" +
TextBox2.Text + "',age='" + TextBox3.Text + "' where Id='" + TextBox1.Text +
"'", con);
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('Data has been Updated')</script>");
GridView1.DataBind();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}

protected void Button3_Click(object sender, EventArgs e)


{
SqlCommand cmd = new SqlCommand("delete from std where Id='" +
TextBox1.Text + "'", con);
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('Data has been Deleted')</script>");
GridView1.DataBind();
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}

protected void Button4_Click(object sender, EventArgs e)


{
string find = "select * from std where (Id like '%' +@Id+ '%')";
SqlCommand cmd = new SqlCommand(find, con);
cmd.Parameters.Add("Id", SqlDbType.NVarChar).Value =
TextBox1.Text;
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds, "Id");
GridView1.DataSourceID = null;
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
Label4.Text = "data has been selected";
}

protected void Button5_Click(object sender, EventArgs e)


{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
}
}
}
Output:
Master Page

Masterpage

<%@ Master Language="VB" CodeFile="MasterPage.master.vb"


Inherits="MasterPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Grocery Mangaement</title>
<asp:ContentPlaceHolder id="head" runat="server">
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-
scale=1.0"></asp:ContentPlaceHolder>
</head> <body>
<form id="form1" runat="server">
<div style="height: 16px">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
<div class="form">
<div class="btn">
<button class="signUpBtn">
SIGN UP
</button>
</div>
<form class="signUp" action="" method="get">
<div class="formGroup">
<input type="text" id="userName" placeholder="User Name"
autocomplete="off">
</div>
<div class="formGroup">
<input type="email" placeholder="Email ID" name="email" required
autocomplete="off">
</div>
<div class="formGroup">
<input type="password" id="password" placeholder="Password" required
autocomplete="off">
</div>
<div class="formGroup">
<input type="password" id="confirmPassword" placeholder="Confirm
Password" required autocomplete="off">
</div>
<div class="checkBox">
<input type="checkbox" name="checkbox" id="checkbox">
<span class="text">I agree with term & conditions</span>
</div>
<div class="formGroup">
<a href='Default2.aspx'>
;
font-weight: 600;
}
.btn2:hover{
background-color: rgba(10, 136, 43, 0.5);
}
.btn button:hover{
border-bottom: 2px solid rgb(91, 243, 131);
}

Default.aspx

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"


AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
</asp:Content>

Default2.aspx

<%@ Page Language="VB" AutoEventWireup="false"


CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link rel="stylesheet" href="stylesheet2.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Grocery Shopping</title>

</head>
<body>

<form id="form1" runat="server">


<div>
<div class="menu" id="sticky">
<ul class="menu-ul">
<a href='#' class="a-menu" ><li>Home</li></a>
<a href='#fru' class="a-menu" ><li>Fruits</li></a>
<a href='#veg' class="a-menu" ><li>Vegetables</li></a>
</ul>
</div>
<!--home page begins-->
<div class="container">
<a href="#fru">
<div class="categories">
<img src="fruit.jpg" class="item" />
<div class="img-title">Fruits</div>
</div>
</a>
<a href="#veg">
<div class="categories">
<img src="home-img.png" class="item" />
<div class="img-title">Vegetables</div>
</div>
</a>
<!--fruits begins-->
<div class="deal-container" id="fru">
<div class="parallax">
<div class="title">FRUITS</div>
</div>
<div class="item">
<div class="image">
<img src="mango.jpg" class="img-size" />
</div>
<div class="des">
<b>Mango</b><br />
<div class="item-select">
price:Rs.80/1kg
</div>
<label>Qty:</label>
<select class="item-select">
<option>1kg</option>
<option>2kg</option>
<option>3kg</option>
<option>4kg</option>
<option>5kg</option>
</select><br />
<button class="buynow">Buy Now</button>
</div>
</div>
<div class="item">
<div class="image">
<img src="wmfr.jpg" class="img-size" />
</div>
<div class="des">
<b>Water melon</b><br />
Output:
Master page:

Web page:
Simple Web Page Using CSS

<!DOCTYPE html>

<html lang="en">

<head>

<style>

/* Styling the body */

body {

margin: 0;

padding: 0;

section {

width: 100%;

height: 100vh;

background:

url('https://media.geeksforgeeks.org/wp-
content/uploads/20210408155049/gfg9.png');

background-size: cover;

section .leftBox {

width: 50%;

height: 100%;

float: left;

padding: 50px;

box-sizing: border-box;

section .leftBox .content {


color: #fff;

background: rgba(0, 0, 0, 0.5);

padding: 40px;

transition: .5s;

section .leftBox .content:hover {

background: #e91e63;

<h3>

Where is the event happening? </h3>

<p> With the idea of imparting programming knowledge, Mr. Sandeep


Jain, an IIT Roorkee alumnus started a dream, GeeksforGeeks. Whether
programming </p>

<a href="#">View Details</a>

</div>

<div style="clear:both;"></div>

</li>

<li> <div class="time">

<h2> 12 <br><span>August</span> </h2>

</div>

<div class="details">

<h3> Where is the event happening? </h3>

<p> With the idea of imparting programming knowledge, Mr. Sandeep Jain,
an IIT Roorkee alumnus started a dream, GeeksforGeeks. Whether
programming </p>

<a href="#">View Details</a> </div>

<div style="clear:both;"></div>
</li> </ul>

</div>

</section>

</body>

</html>
Output:

You might also like