0% found this document useful (0 votes)
46 views45 pages

Software Lab - 8

The document discusses the .NET Framework. It provides an introduction to the .NET Framework, describing it as a software framework developed by Microsoft that allows programs written in multiple languages to run. It outlines some of the main components of the .NET Framework including the Common Language Runtime and Framework Class Library.

Uploaded by

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

Software Lab - 8

The document discusses the .NET Framework. It provides an introduction to the .NET Framework, describing it as a software framework developed by Microsoft that allows programs written in multiple languages to run. It outlines some of the main components of the .NET Framework including the Common Language Runtime and Framework Class Library.

Uploaded by

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

GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT

GANGA INSTITUTE OF TECHNOLOGY AND


MANAGEMENT
DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS

SOFTWARE LAB -8
(Based on 21MCA24C3)

Submitted To: Submitted By:

NAME-………………….

ROLL NO……………….

GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT

INDEX

SR. DATE OF PAGE TEACHER’S


NO TOPIC PRACTICAL NO. SIGNATURE

1. Introduction to .NET Framework.

Write a program to display message


2 (a).
in VB.net using message Box.
Write a program to display message
2 (b).
in C# using message Box.
Write a calculator program in
3.
VB.NET.
Write a program for constructor in
4(a).
VB.NET.
Write a program to implement
4(b).
interface in VB.NET.
Write a program to implement
5(a).
overloading.
Write a program to implement
5(b).
overriding.
Write a program to implement jagged
6(a).
array.
6(b). Write a program for an array list.
Write a program to implement hash
6(c).
table.
Write a program to implement
7(a).
multicast Delegates.
Write a program to implement
7(b).
multicast Events.
Write a program to implement
8. ADO.net Connectivity via user
interface.
Write a program TO demonstrate ado
9.
connectivity viva coding in asp.net.
Write a program TO demonstrate
10.
asp.net Web form.

Introduction to .NET Framework


GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT

.NET Framework (pronounced dot net) is a software framework developed


by Microsoft that runs primarily on Microsoft Windows. It includes a large class
library named Framework Class Library (FCL) and provides language
interoperability (each language can use code written in other languages) across
several programming languages. Programs written for .NET Framework execute in
a software environment (in contrast to a hardware environment) named Common
Language Runtime(CLR), an application virtual machine that provides services such as
security, memory management, and exception handling. (As such, computer code written
using .NET Framework is called "managed code".) FCL and CLR together constitute .NET
Framework.
FCL provides user interface, data access, database connectivity, cryptography, web
application development, numeric algorithms, and network communications. Programmers
produce software by combining their source code with .NET Framework and other
libraries. The framework is intended to be used by most new applications created for the
Windows platform. Microsoft also produces an integrated development
environment largely for .NET software called Visual Studio.
.NET Framework began as proprietary software, although the firm worked
to standardize the software stack almost immediately, even before its first release. Despite
the standardization efforts, developers, mainly those in the free and open-source
software communities, expressed their unease with the selected terms and the prospects of
any free and open-source implementation, especially regarding software patents. Since
then, Microsoft has changed .NET development to more closely follow a contemporary
model of a community-developed software project, including issuing an update to its
patent promising to address the concerns.
.NET Framework led to a family of .NET platforms targeting mobile
computing, embedded devices, alternative operating systems, and web browser plug-ins. A
reduced version of the framework, .NET Compact Framework, is available on Windows
CE platforms, including Windows Mobile devices such as smartphones. .NET Micro
Framework is targeted at very resource-constrained embedded devices. Silverlight was
available as a web browser plugin. Mono is available for many operating systems and is
customized into popular smartphone operating systems (Android and iOS) and game
engines. .NET Core targets the Universal Windows Platform (UWP), and cross-
platform and cloud computing workloads.
Common Language Infrastructure (CLI) provides a language-neutral platform for
application development and execution, including functions for exception
handling, garbage collection, security, and interoperability. By implementing the core
aspects of .NET Framework within the scope of CLI, these functions will not be tied to
one language but will be available across the many languages supported by the framework.

GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT

Microsoft's implementation of CLI is Common Language Runtime (CLR). It serves as the


execution engine of .NET Framework. All .NET programs execute under the supervision
of CLR, guaranteeing many properties and behaviors in the areas of memory management,
security, and exception handling.
For computer programs to run on CLI, they need to be compiled into Common
Intermediate Language (CIL) – as opposed to being compiled into machine code. Upon
execution, an architecture-specific just-in-time compiler (JIT) turns the CIL code into
machine code. To improve performance, however, .NET Framework comes with Native
Image Generator (NGEN), which performs ahead-of-time compilation.
.NET Framework includes a set of standard class libraries. The class library is organized in
a hierarchy of namespaces. Most of the built-in application programming interfaces (APIs)
are part of either  System.*  or  Microsoft.*  namespaces. These class libraries implement
many common functions, such as file reading and writing, graphic rendering, database
interaction, and XML document manipulation. The class libraries are available for all CLI
compliant languages. The class library is divided into two parts (with no clear
boundary): Base Class Library (BCL) and Framework Class Library (FCL).
BCL includes a small subset of the entire class library and is the core set of classes that
serve as the basic API of CLR.[38]For .NET Framework most classes considered being part
of BCL reside in  mscorlib.dll ,  System.dll  and  System.Core.dll . BCL classes are available
in .NET Framework as well as its alternative implementations including .NET Compact
Framework, Microsoft Silverlight, .NET Core and Mono.
FCL is a superset of BCL and refers to the entire class library that ships with .NET
Framework. It includes an expanded set of libraries, including the Windows
Forms, ASP.NET, and Windows Presentation Foundation (WPF) but also extensions to the
base class libraries ADO.NET, Language Integrated Query (LINQ), Windows
Communication Foundation (WCF), and Workflow Foundation (WF). FCL is much larger
in scope than standard libraries for languages like C++, and comparable in scope
to standard libraries of Java.
With the introduction of alternative implementations (e.g., Silverlight), Microsoft
introduced the concept of Portable Class Libraries (PCL) allowing a consuming library to
run on more than one platform. With the further proliferation of .NET platforms, the PCL
approach failed to scale (PCLs are defined intersections of API surface between two or
more platforms).[39] As the next evolutionary step of PCL, the .NET Standard Library was
created retroactively based on the  System.Runtime.dll based APIs found in UWP and
Silverlight. New .NET platforms are encouraged to implement a version of the standard
library allowing them to re-use extant third-party libraries to run.

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.

11 Programming Languages which are designed and developed by Microsoft are:

 C#.net
 Vb.net
 C++.net
 J#.net
 F#.net
 JSCRIPT.net
 WindownsPowershell
 Iron Ruby
 Iron Python
 Comega

ASML (Abstract State Machine Language)

Main Components of .NET Framework

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

Is .NET application platform dependent or platform independent?

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

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MessageBox.Show("Welcome to VB.NET")
End Sub
End Class

Output:-

GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT

2 (b)Write a program to display message in C# using message Box


Coding
using System;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingSystem.Windows.Forms;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Welcome to C#");
}
}
}

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:-

Addition of two integer

Subtraction of two integer

GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT

Multiplication of two integer

Division of two integer

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

4(b) Write a program to implement interface in VB.NET


Coding
ImportsConsoleApp
Module Module1
Public Interface Interface1
Function Add(ByVal x As Integer) As Integer
End Interface
Public Class first
Implements Interface1
Public Function Add(x As Integer) As Integer Implements Interface1.Add
Console.WriteLine("Implementing x+x in first class::"& (x + x))
' Throw New NotImplementedException()
End Function
End Class
Public Class second
Implements Interface1
Public Function Add(x As Integer) As Integer Implements Interface1.Add
Console.WriteLine("Implementing x+x in second class::"& (x + x + x))
' Throw New NotImplementedException()
End Function
End Class
Sub Main()
Dim obj1 As New first
Dim obj2 As New second
obj1.Add(10)
obj2.Add(50)
Console.Read()
End Sub
End Module

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

5(b) Write a program to implement overriding


Coding
using System;
namespace ConsoleApp8
{
public class Customer
{
public virtual void CustomerType()
{
Console.WriteLine("I am a customer");
}
}
public class CorporateCustomer : Customer
{
public override void CustomerType()
{
//base.CustomerType();
Console.WriteLine("I am a corporate customer");
}
}
public class PersonalCustomer : Customer
{
public override void CustomerType()
{
Console.WriteLine("I am personal customer");
//base.CustomerType();
}
}
public class MainClass
{
public static void Main(String[] args)
{
Customer[] p = new Customer[3];
p[0] = new CorporateCustomer();
p[1] = new PersonalCustomer();
p[2] = new Customer();
foreach (Customer program1Object in p)
{
program1Object.CustomerType();
}
//Console.WriteLine("Hello World!");
}
}
}
Output:-

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

6 (b) Write a program for an array list


Coding
using System;
usingSystem.Collections;
namespace ConsoleApp7
{
public class Program
{
public static void Main(string[] args)
{
ArrayList a1 = new ArrayList();
a1.Add(1);
a1.Add("Two");
a1.Add('a');
a1.Add(4.5);
ArrayList a11 = new ArrayList();
a11.Add(100);
a11.Add(200);
// adding entire collection
a1.AddRange(a11);
for(inti=0;i<a1.Count;i++)
Console.WriteLine(a1[i]);
}
}
}

GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT

Output:-

GITAM
GANGA INSTITUTE OF TECHNOLOGY AND MANAGEMENT

6 (c) Write a program to implement hash table


Coding
using System;
usingSystem.Collections;
namespace ConsoleApp9
{
class Program
{
static void Main(string[] args)
{
Hashtableht = new Hashtable();
ht[1] = "one";
ht[13] = "thirteen";
ht[5] = "five";
foreach (DictionaryEntry entry in ht)
{
Console.WriteLine("{0},{1}",entry.Key,entry.Value);
//Console.Read();
}
//Console.WriteLine("Hello World!");
}
}
}

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

7 (b) Write a program to implement multicast Events.


Coding
using System;
namespace ConsoleApp13
{
delegate void clickHandle();
classCalculatorEvent
{
public event clickHandleclickTasks;
public void onOperations()
{
if (clickTasks != null)
clickTasks();
else
Console.WriteLine("Please register a handler to an event!");
}
}
class Add
{
public void addition()
{
Console.WriteLine("Addition Answer: {0}",(10+2));
}
}
class Subtract
{
public void subtraction()
{
Console.WriteLine("sub. Answer: {0}", (10 - 2));
}
}
class Multiply
{
public void multiplication()
{
Console.WriteLine("Multiplication. Answer: {0}", (10 * 2));
}
}
classDivid
{
public void division()
{
Console.WriteLine("division. Answer: {0}", (10 / 2));
}
}
class Program

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.

Step2: Click on Create a new project. Then click on ASP.NET Web


Application (framework) and choose language C#, choose all platform, choose
all project type. Finally click on next button.

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)
{}

protectedvoid TextBox1_TextChanged(object sender, EventArgs e)


{}

protectedvoid Button1_Click(object sender, EventArgs e)


{
TextArea.Text = "Father's Name: \t" + fnametxt.Text + "\n" + "Roll Number: \t"
+ regNoTxt.Text + "\n" + "Course: \t" + coursetxt.Text + "\n" + "College:\t "
+ collegetxt.Text;
}

protectedvoid TextBox1_TextChanged1(object sender, EventArgs e)


{}
}
}

Coding in .aspx file


<
%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs"Inherits="WebApplication3.W
ebForm1"%>

<!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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBoxID="fnametxt"runat="server"></asp:TextBox>
</p>

Course&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;
<asp:TextBoxID="coursetxt"runat="server"></asp:TextBox>
<p>
College Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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">
&nbsp;</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

You might also like