Software Lab - 8
Software Lab - 8
SOFTWARE LAB -8
(Based on 21MCA24C3)
NAME-………………….
ROLL NO……………….
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
INDEX
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 1
Introduction to .NET Framework
.NET is a software framework which is designed and developed by Microsoft. The first version of .Net framework
was 1.0 which came in the year 2002. In easy words, it is a virtual machine for compiling and executing programs
written in different languages like C#, VB.Net etc.
It is used to develop Form-based applications, Web-based applications, and Web services. There is a variety of
programming languages available on the .Net platform, VB.Net and C# being the most common ones. It is used to
build applications for Windows, phone, web etc. It provides a lot of functionalities and also supports industry
standards.
.NET Framework supports more than 60 programming languages in which 11 programming languages are
designed and developed by Microsoft. The remaining Non-Microsoft Languages which are supported by .NET
Framework but not designed and developed by Microsoft.
C#.net
Vb.net
C++.net
J#.net
F#.net
JSCRIPT.net
WindownsPowershell
Iron Ruby
Iron Python
Comega
Common Language Runtime(CLR): CLR is the basic and Virtual Machine component of the .NET
Framework. It is the run-time environment in the .NET Framework that runs the codes and helps in
making the development process easier by providing the various services such as remoting, thread
management, type-safety, memory management, robustness etc.. Basically, it is responsible for managing
the execution of .NET programs regardless of any .NET programming language. It also helps in the
management of code, as code that targets the runtime is known as the Managed Code and code doesn’t
target to runtime is known as Unmanaged code.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Framework Class Library(FCL): It is the collection of reusable, object-oriented class libraries and
methods etc that can be integrated with CLR. Also called the Assemblies. It is just like the header files in
C/C++ and packages in the java. Installing .NET framework basically is the installation of CLR and FCL
into the system. Below is the overview of .NET Framework
The combination of Operating System Architecture and CPU Architecture is known as the platform.
Platform dependent means the programming language code will run only on particular Operating System.
A .NET application is platform dependent because of the .NET framework which is only able to run on
the Windows-based operating system. The .Net application is platform independent also because of Mono
framework. Using Mono framework the .Net application can run on any Operating System including
windows. Mono framework is a third party software developed by Novell Company which is now a part
of Micro Focus Company. It is a paid framework.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 2
(a) Write a program to display message in VB.net using message Box.
Coding
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 3
Write a program of calculator in VB.NET
Coding
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a + b
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a - b
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a * b
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a / b
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 4
(a) Write a program of constructor in VB.NET
Coding
Module Module1
Public Class Sample
Private a As Integer
Public Sub New(ByValsetval As Integer)
a = setval
End Sub
Public Function disp()
Return a
End Function
End Class
Sub Main()
Dim d As New Sample(5)
Console.WriteLine("Value of a is initialized to:")
Console.WriteLine(d.disp())
Console.Read()
End Sub
End Module
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 5
(a)Write a program to implement overloading
Coding
using System;
namespace ConsoleApp6 {
classCalc{
public void add(int a, int b)
{
Console.WriteLine("The sum of a and b is: "+(a+b));
}
public void add(int a, int b, int c)
{
Console.WriteLine("The sum of a, b and c is: "+(a+b+c));
}
public void add(int a, int b, int c, int d)
{
Console.WriteLine("The sum of a, b, c, and d is: "+(a+b+c+d));
}
}
class Program
{
static void Main(string[] args)
{
Calccal = new Calc();
cal.add(3,4);
cal.add(3, 4,5);
cal.add(3, 4,5,6);
Console.ReadKey();
}
}
}
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 6
(a) Write a program to implement jagged array
Coding
using System;
namespace ConsoleApp7
{
class Program
{
static void Main(string[] args)
{
//int [][]jaggedArray=new int [3][];
int[][] jaggedArray = new int[3][];
jaggedArray [0] = new int [2] { 2,5};
jaggedArray[1] = new int[3] { 2, 5,4 };
jaggedArray[2] = new int[4] { 2, 5,9,6 };
//Display the array element
for (inti=0;i <jaggedArray.Length;i ++)
{
System.Console.Write("Element ({0}):", i + 1);
//Console("Element ({0}):", i + 01);
//Console.Write("Element ({0}):", i + 1);
for (int j=0;j<jaggedArray[i].Length; j++)
{
Console.Write(jaggedArray[i][j] + "\t");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 7
(a) Write a program to implement multicast Delegates.
Coding
using System;
namespace ConsoleApp22{
classMathClass {
publicint add(int a, int b) {
return a + b;
}
publicint sub(int a, int b)
{
return a - b;
}
}
public delegate intDelegateMath(intx,int y);
class Program
{
static void Main(string[] args){
DelegateMath de1;
DelegateMath de2;
DelegateMath de3;
MathClassmathclass = new MathClass();
de1 = mathclass.add;
Console.WriteLine("Value for first delegate");
Console.WriteLine(de1(10, 20));
de2 = mathclass.sub;
Console.WriteLine("Value for second delegate");
Console.WriteLine(de1(20, 12));
de3 = de1 + de2;
Console.WriteLine("Value for third delegate");
Console.WriteLine(de3(20,10));
}
}
}
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
{
static void Main(string[] args)
{
CalculatorEventcalEvent = new CalculatorEvent();
Add add = new Add();
Subtract sub = new Subtract();
Multiply mul = new Multiply();
Divid div = new Divid();
/* This is a multicast chainEvent */
calEvent.clickTasks += add.addition;
calEvent.clickTasks += sub.subtraction;
calEvent.clickTasks += mul.multiplication;
calEvent.clickTasks += div.division;
//Event is Triggered by onOperation() method
calEvent.onOperations();
Console.WriteLine();
//Through -= opereator handler (method) is removed /unregistered from an event chain
calEvent.clickTasks -= div.division;
// call again
calEvent.onOperations();
Console.ReadKey();
}}}
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM NO 8
Write a program to implement ADO.net Connectivity via user interface.
Coding
Step1: First open the Visual Studio.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step3: Write the name of the project and choose desired location where you want to save
the project file and its resources of the project. Then change the name of the
solution name of the project and choose which type of framework environment
you want to work for your project. Finally click on Create button to create
an environment to work on your project.
Step: 4 Choose the Web Forms and click on Create button to have environment for project.
Finally click on Create button to have a Web environment to work for the project.
Then a window will appear as per given below:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step: 5 Right click on the project name inside the solution explorer then goto Add option
and finally click on the AddItem… or press a shortcut key is Ctrl+Shift+A.
Then a window appears as per given below:-
Step: 6 Choose Web Form from list given in the window of Add New Item and change the
name of the Web Form as per your requirement in the project, but its extension
will be .aspx. Finally click on Add button.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step: 7 After the Click on Add button then a new window appear to the window screen as per shown
below:-
Step: 8 Click on Design tab at the bottom of the window screen to goto design view of
the Web Form in which you can add grid view inside the Web Form which help in
your project.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step: 9 Click on Toolbox then all the tools will appear from which we can choose anything
as per your project want for it. But now the project want for Grid View so then we
choose Grid View from the Toolbox. We can easy choose Grid View from
the toolbox by using the search tool to search different types of tools present in
the Web Form.
Step: 10 Then drag the GirdView tool from the toolbox to design view of the Web Form where we
can design the web page or web site. Inside the design view the GridView look like as
per given below:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step: 11When you click on the small arrow key of the following window will appear
and then click on new data source then a Data Source Configuration Wizard
window appears.
From Data Source Configuration Wizard choose any source of data type form
which you want to handle data with ASP.Net web forms. Finally click on OK
button to proceed future.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step: 12Click on the New Connection… and then an Add Connection window appears
on the window screen. Then write server name from which it is connected
through the database and write the name of the database name which is used
to connect with web form. Finally test the database file and click on OK button.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step: 13 Click on the Next button from the Configure Data Source – SqlDataSource1
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step: 14 Click on the Next button from the Configure Data Source – SqlDataSource1
Step: 15Click on the Next button from the Configure Data Source – SqlDataSource1.
In this window we can test the query which are applied for the project of
Web Form in .aspx environment.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
Step: 16Finally click on Finish button and then press Ctrl+F5 to execute it.
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 9
Write a program TO demonstrate ado connectivity viva coding in asp.net.
Coding
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Data;
usingSystem.Data.SqlClient;
namespace Web10
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnectionSQLCon = new SqlConnection(@"Data Source = DESKTOP-UT7BCNL; Initial Catalog =
preetiakku; Integrated Security = True");
SqlDataAdapter SQLDA = new SqlDataAdapter("select * from t_1", SQLCon);
DataSetds = new DataSet();
SQLDA.Fill(ds, "t_1");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}
Output:-
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
PROGRAM 10
Write a program to demonstrate asp.net. webform
Coding in C#
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
namespace WebApplication3
{
publicpartialclassWebForm1 :System.Web.UI.Page
{
protectedvoidPage_Load(object sender, EventArgs e)
{}
<!DOCTYPEhtml>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
#TextArea1 {
height: 172px;
width: 521px;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>
Registration No.<asp:TextBoxID="regNoTxt"runat="server"style="margin-left:
22px"></asp:TextBox>
</div>
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
<p>
Full
Name
<asp:TextBoxID="fnametxt"runat="server"></asp:TextBox>
</p>
Course &
nbsp;
<asp:TextBoxID="coursetxt"runat="server"></asp:TextBox>
<p>
College Name
<asp:TextBoxID="collegetxt"runat="server"></asp:TextBox>
</p>
<ptitle="Display Detail">
<asp:ButtonID="displaybtn"runat="server"OnClick="Button1_Click"Text="Display
Detail"Width="129px"/>
</p>
<ptitle="Display Detail">
</p>
<ptitle="Display Detail">
<asp:TextBoxID="TextArea"runat="server"OnTextChanged="TextBox1_TextChanged1"TextMode="MultiLine"H
eight="189px"Width="445px"></asp:TextBox>
</p>
</form>
</body>
</html>
GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT
OUTPUT
GITAM