Practical File (BCA0504) : Submitted To: Submitted By: A.P. Anchal Kumari . Roll No.: .
Practical File (BCA0504) : Submitted To: Submitted By: A.P. Anchal Kumari . Roll No.: .
ASP.NET Technologies
(BCA0504)
1
INDEX
Sr.No. Activity Page Remarks
No.
1. Introduction to .Net Framework 3-6
2. Introduction to ASP.Net Technologies 7-8
3. Write a simple program to print a number from1 to 10 using 9
the DO While Loop in VB.Net.
4. Write a simple program to print a Table in VB.Net. 10
3. Write a program in which program take an input form the 11
user and check whether the number is Prime or Not.
5. Write a program in which program will get an input from 12
the user and find the Factorial of given number.
6. Write a program to make 3rd matrix by Multiply Two Matrix. 13-14
7. Write a program to Swap Two Numbers without Third 15
variable.
8. Write a program to demonstrates the concept of Select 16
Case.
9. Write a program to perform the function that take two 17
numbers from user as input and then divide first number by
the second number.
10. Write a program to show the server & client side control. 18
11. Write a program to show the use of AutoPostBack Property. 19-20
12. Write a program to show the use of runat server control. 21-22
13. Write a program to differentiate between Div & Span tag. 23
14. Write a program to show the use of Table tag in asp.net 24-25
15. Write a program to show the use of any four-input control in 26
asp.net.
16. Write a program to show the use of Link Button and 27-28
Hyperlink in asp.net.
17. Write a program to show the use of Link button and panels 29
in asp.net.
18. Write a program to show the use of Validation Control in 30-31
asp.net.
19. Write a program to create user control dynamically in 32-33
asp.net.
20. Write a program to show the use of Simple List Control and 34-35
template control in asp.net.
21. Write a program to design a login page using if else in 36-37
asp.net.
22. Write a program to show the use of month calendar in 38
asp.net.
23. Write a program to show the use of State Management in 39
asp.net.
24. Write a program to create placeholder in asp.net. 40
2
Introduction To .Net FrameWork
.NET is a framework to develop software applications. It is designed and developed by
Microsoft and the first beta version released in 2000.
It is used to develop applications for web, Windows, phone. Moreover, it provides a broad
range of functionalities and support.
This framework contains a large number of class libraries known as Framework Class Library
(FCL). The software programs written in .NET are executed in the execution environment,
which is called CLR (Common Language Runtime). These are the core and essential parts of
the .NET framework.
This framework provides various services like memory management, networking, security,
memory management, and type-safety.
4. Other Modules (WCF, WPF, WF, Card Space, LINQ, Entity Framework, Parallel LINQ, Task
Parallel Library, etc.)
3
CLR (COMMON LANGUAGE RUNTIME)
.NET CLR is a runtime environment that manages and executes the code written in any .NET
programming language. CLR is the virtual machine component of the .NET framework.
That language's compiler compiles the source code of applications developed using .NET
compliant languages into CLR's intermediate language called MSIL, i.e., Microsoft intermediate
language code. This code is platform-independent. It is comparable to byte code in java.
Metadata is also generated during compilation and MSIL code and stored in a file known as
the Manifest file. This metadata is generally about members and types required by CLR to
execute MSIL code. A just-in-time compiler component of CLR converts MSIL code into native
code of the machine. This code is platform-dependent. CLR manages memory, threads,
exceptions, code execution, code safety, verification, and compilation.
The following figure shows the conversion of source code into native code.
The above figure converts code into native code, which the CPU can execute.
o Garbage Collector
4
Common type system:
CTS provides guidelines for declaring, using, and managing data types at runtime. It offers
cross-language communication. For example, VB.NET has an integer data type, and C# has an int
data type for managing integers. After compilation, Int32 is used by both data types. So, CTS
provides the data types using managed code. A common type system helps in writing
language-independent code.
1. Value Type: A value type stores the data in memory allocated on the stack or inline in a
structure. This category of Type holds the data directory. If one variable's value is copied to
another, both the variables store data independently. It can be of inbuilt-in types, user-
defined, or enumerations types. Built-in types are primitive data types like numeric, Boolean,
char, and date. Users in the source code create user-defined types. An enumeration refers
to a set of enumerated values represented by labels but stored as a numeric type.
5
2. Reference Type: A Reference type stores a reference to the value of a memory address
and is allocated on the heap. Heap memory is used for dynamic memory allocation.
ReferenceType does not hold actual data directly but holds the address of data. Whenever a
reference type object is made, it copies the address and not actual data. Therefore, two
variables will referto the same data. If data of one Reference Type object is changed, the same
is reflected for the other object.
Garbage Collection:
Garbage Collector is a component of CLR that works as an automatic memory manager. It helps
manage memory by automatically allocating memory according to the requirement. It allocates
heap memory to objects. When objects are not in use, it reclaims the memory allocated to them
for future use. It also ensures the safety of objects by not allowing one object to use the content of
another object.
JIT Compiler is an important component of CLR. It converts the MSIL code into native code
(i.e., machine-specific code). The .NET program is compiled either explicitly or implicitly. The
developer or programmer calls a particular compiler to compile the program in the explicit
compilation. In implicit compilation, the program is compiled twice. The source code is
compiled into Microsoft Intermediate Language (MSIL) during the first compilation process.
The MSIL code is converted into native code in the second compilation process. This processis
called JIT compilation.
Metadata:
A Metadata is a binary information about the program, either stored in a CLR Portable
Executable file (PE) along with MSIL code or in the memory. During the execution of MSIL,
metadata is also loaded into memory for proper interpretation of classes and related.
Information used in code. So, metadata helps implement code in a language-neutral manner
or achieve language interoperability.
6
ASP.Net Technologies
It is a web framework designed and developed by Microsoft. It is used to develop websites, web
applications and web services. It provides fantastic integration of HTML, CSS and JavaScript. It
was first released in January 2002. It is built on the Common Language Runtime (CLR) and allows
programmers to write code using any supported .NET language.
ASP.NET is a part of Microsoft .NET Framework. The following image shows the component stack.
Web Forms
ASP.NET MVC
It gives us a MVC (Model View Controller), patterns-based way to build dynamic websites. It
enables a clean separation of concerns and that gives you full control over markup for enjoyable,
agile development. It also provides many features that enable fast development for creating
outstanding applications. We will discuss it further in next chapters.
It is used to create dynamic web pages. It provides fast and lightweight way to combine server
code with HTML. It helps to add video, link to the social sites. It also provides other features like
you can create beautiful sites that conform to the latest web standards.
All these are stable and well equipped frameworks. We can create web applications with any of
them. These are also based on the .NET Framework and share core functionalities of .NET and
ASP.NET.
We can use any development style to create application. The selection of style is depends on the
skills and experience of the programmer.
Although each framework is independent to other, we can combine and use any of that at any
level of our application. For example, to develop client interaction module, we can use MVC and for
data control, we can use Web Forms.
7
The following table illustrates each development model:
MVC Ruby on Full control over HTML markup, code and markup Mid-Level,
Rails, .NET separated, and easy to write tests. The best choice Advanced
for mobile and single-page applications (SPA).
Web Classic HTML markup and your code together in the same New, Mid-Level
Pages ASP, PHP file
8
1. Write a simple program to print a number from 1 to 10 using the Do
While Loop in VB.Net.
Module Module1
Sub Main()
' Initializatio and Declaration of variable i
Dim i As Integer = 1
Do
' Executes the following Statement
Console.WriteLine(" Value of variable I is : {0}", i)
i = i + 1 'Increment the variable i by 1
Loop While i <= 10 ' Define the While Condition
Console.WriteLine(" Press any key to exit...")
Console.ReadLine()
End Sub
End Module
Output:
9
2. Write a simple program to print a Table in VB.Net.
Module Module1
Sub Main()
'declaration of i and num variable
Dim i, num As Integer
Console.WriteLine(" Enter any number to print the table")
num = Console.ReadLine()
' accept a number from the user
Console.WriteLine(" Table of " & num)
'define for loop condition, it automatically initialize step to 1
For i = 1 To 10
Console.WriteLine(num & " * " & i & " = " & i * num)
Next
Console.ReadLine()
End Sub
End Module
Output:
10
3. Write a program in which program take an input from the user
and check whether the number is Prime or Not.
Module Module1
Sub Main()
Aditya:
Dim n, i, m, flag As Integer
m = 0
flag = 0
Console.Write("Enter the number to check prime:")
n = Console.ReadLine()
m = n / 2
For i = 2 To m Step 1
If n Mod i = 0 Then
Console.WriteLine("Number is not prime")
flag = 1
Exit For
End If
Next
If flag = 0 Then
Console.WriteLine("Number is prime.")
End If
GoTo Aditya
Console.ReadLine()
End Sub
End Module
Output:
11
4. Write a program in which program will get an input form the
user and find the Factorial of given Number.
Module Module1
Sub Main()
Aditya:
Dim i, fact, number As Integer
fact = 1
Console.Write("Enter a number:")
number = Console.ReadLine()
End Sub
End Module
Output:
12
5. Write a program to make 3rd Matrix by Multiply by Two Matrix.
Module Module1
Sub Main()
Dim a(3, 3), b(3, 3), mul(3, 3) As Integer
Dim r, k As Integer
For r = 0 To 2 Step 1
For k = 0 To 2 Step 1
Console.Write("Enter the A({0},{1}) element to array A:", r, k)
a(r, k) = Console.ReadLine()
Next
Next
Console.WriteLine()
For r = 0 To 2 Step 1
For k = 0 To 2 Step 1
Console.Write("Enter the B({0},{1}) element to array B:", r, k)
b(r, k) = Console.ReadLine()
Next
Next
Console.WriteLine()
For r = 0 To 2 Step 1
For k = 0 To 2 Step 1
For j = 0 To 2 Step 1
mul(r, k) += a(r, j) * b(j, k)
Next
Next
Next
Console.WriteLine()
For r = 0 To 2 Step 1
For k = 0 To 2 Step 1
Console.Write("{0} ", a(r, k))
Next
Console.WriteLine()
Next
Console.WriteLine()
For r = 0 To 2 Step 1
For k = 0 To 2 Step 1
Console.Write("{0} ", b(r, k))
Next
Console.WriteLine()
Next
Console.WriteLine()
For r = 0 To 2 Step 1
For k = 0 To 2 Step 1
Console.Write("{0} ", mul(r, k))
Next
13
Console.WriteLine()
Next
Console.ReadLine()
End Sub
End Module
Output:
14
6. Write a program to Swap Two Numbers without Third variable.
Module Module1
Sub Main()
Dim a, b As Integer
a = 3
b = 13
Console.WriteLine("Before swap A={0} and B={1}", a, b)
a = a + b
b = a - b
a = a - b
Console.WriteLine("After swap A={0} and B={1}", a, b)
Console.ReadLine()
End Sub
End Module
Output:
15
7. Write a to demonstrates the concept of Select Case.
Module Module1
Sub Main()
Dim a As Integer
Console.Write("Enter day number:")
a = Console.ReadLine()
Select Case a
Case 1
Console.WriteLine("Sunday")
Case 2
Console.WriteLine("Monday")
Case 3
Console.WriteLine("Tuesday")
Case 4
Console.WriteLine("Wednesday")
Case 5
Console.WriteLine("Thursday")
Case 6
Console.WriteLine("Friday")
Case 7
Console.WriteLine("Saturday")
Case Else
Console.WriteLine("Wrong Input")
End Select
Console.ReadLine()
End Sub
End Module
Output:
16
8. Write a program to perform the function that take two number
from user as input & then divide the first number by the second
number.
Module Module1
Function Add(ByVal a As Integer, ByVal b As Integer) As Integer
Dim c As Integer
c = a / b
Console.WriteLine("The Division is :" & c)
End Function
Sub Main()
Dim a, b, c As Integer
Console.WriteLine("Enter First Number:")
a = Console.ReadLine()
Console.WriteLine("Enter Second Number:")
b = Console.ReadLine()
c = Add(a, b)
Console.ReadLine()
End Sub
End Module
Output:
17
9. Write a program to show the server & client-side control.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<h1>Client Side controls never execute on server. It execute on
browers.</h1>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="textbox1" runat="server"></asp:TextBox>
<asp:Button ID ="Button1" runat="server" Text="Button" /><br />
<asp:Label runat="server" Text="*Server side control alway written
inside the form control. You can change client side control into the
server-side control by writting runat= attritbute as a attributr in client
side cintro" ForeColor="Red"></asp:Label>
</div>
</form>
</body>
</html>
Output:
18
10. Write a program to show the use of AutoPostBack Property.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
Select City:<br />
<br />
<div>
End Sub
19
Label1.Text = "You have selected:" &
ListBox1.SelectedItem.ToString()
End Sub
End Class
Output:
20
11. Write a program to show the use of runat server control.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
End Sub
21
Output:
When we click the button after entering text, it responses back to client:
22
12. Write a program to differentiate Div and Span tag.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="span" runat="server" style="padding:1px 2px;background-
color:dodgerblue;color:White;font-family:Impact">
div html control is used for block-leverl organization
</div>
<p>A Span elemnet is used for <span id="span1" runat="server"
style="padding:1px 2px;background-color:rgb(22,160,133);color:White;font-
family:Impact"> Inline Organization</span> and styling</p>
</form>
</body>
</html>
Output:
23
13. Write a program to show the use of table tag in ASP.Net.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Table runat="server" BorderStyle="Solid" BorderWidth="2px"
Height="203px" width="339px" BorderColor="Black" GridLines="Both"
HorizontalAlign="Left">
<asp:TableRow runat="server">
<asp:TableCell runat="server">2.</asp:TableCell>
<asp:TableCell runat="server">Vatika Sharma</asp:TableCell>
<asp:TableCell runat ="server">002</asp:TableCell>
<asp:TableCell runat="server" >3216544987</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">3.</asp:TableCell>
<asp:TableCell runat ="server">Aarav</asp:TableCell>
<asp:TableCell runat ="server">003</asp:TableCell>
<asp:TableCell runat="server">125647892</asp:TableCell>
24
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
Output:
25
14. Write a program to show the use of any four-input
control in asp.net.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"Width="200px"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Gender "></asp:Label>
<asp:RadioButton ID="RadioButton1" runat="server" Text="Male" />
<asp:RadioButton ID="RadioButton2" runat="server" Text="Female" />
<br />
<asp:LabelID="Label3"runat="server"Text="SelectCourses:"></asp:Label>
<br />
<asp:CheckBox ID="CheckBox1" runat="server" Text="BCA " />
<asp:CheckBox ID="CheckBox2" runat="server" Text="BBA" />
<asp:CheckBox ID="CheckBox3" runat="server" Text="PGDCA" />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
</div>
</form>
</body>
</html>
Output:
26
15. Write a program to show the use of link button &
hyperlink in asp.net.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p> It is a hyperlink style button</p>
</div>
<asp:LinkButton ID ="Linkbutton1" runat ="server" OnClientClick
="Label">javatpoint</asp:LinkButton>
<p>
<asp:Label ID="Label1" runat="server"></asp:Label>
</p>
<div>
<asp:HyperLink ID="HyperLink1" runat="server" Text="JavaTpoint"
navigationurl="https://www.javatpoint.com/asp-net-
hyperlink"></asp:HyperLink>
</div>
</form>
</body>
</html>
End Sub
27
Output:
28
16. Write a program to show the use of labels & panels in
asp.net.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" BorderColor="#990000"
Borderstyle="Solid" Height="116px" ScrollBars="Both" style="width:278px">
<asp:Label ID="Lable1" runat="server">This is scrollable
panel.</asp:Label>
<br />
<br />
<asp:Button ID="btnpanel" runat="server" Text="Button"
style="width:82px"/>
</asp:Panel>
</div>
</form>
</body>
</html>
Output:
29
17. Write a program to show the use of Validation Control in
asp.net.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td class="style2">
<asp:LabelID="Label1"runat="server"Text="UserName"></asp:Label>
</td>
<td class="style3">
<asp:TextBoxID="TextBox1"runat="server"Width="260px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidatorID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Please Enter Name"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="Label2"runat="server"Text="Password"></asp:Label>
</td>
<td class="style3">
<asp:TextBoxID="TextBox2"runat="server"Width="260px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Please Enter Password"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td class="style3">
30
<asp:ButtonID="Button1"runat="server"Text="Login"/>
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Output:
31
17. Write a program to create user control dynamically in
asp.net.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td>
<asp:Button ID="Button1" runat="server"
Text="Login" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
32
End Sub
Output:
33
18. Write a program to show the use of simple list control &
template control in asp.net.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<p> Select a city of your choice:</p>
</div>
<div>
34
Public Class WebForm1
Inherits System.Web.UI.Page
End Sub
Output:
35
19. Write a program to design a login page usig if else in
asp.net.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 252px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td class="style2">
<asp:LabelID="Label1"runat="server"Text="UserName"></asp:Label>
</td>
<td>
<asp:TextBoxID="TextBox1"runat="server"Width="221px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
<asp:LabelID="Label2"runat="server"Text="Password"></asp:Label>
</td>
<td>
<asp:TextBoxID="TextBox2"runat="server"Width="219px" TextMode ="Password"
></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
36
</td>
<td>
<asp:ButtonID="Button1"runat="server"Text="Login"/>
</td>
</tr>
</table>
</div>
<div>
<asp:Label ID="Label3" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Output:
37
20. Write a program to show the use of month Calendar in
asp.net.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Select Date from the Calendar </h2>
</div>
<div>
<asp:Calendar ID="Calendar1" runat ="server" ></asp:Calendar>
</div>
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body>
</html>
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 Calendar1_SelectionChanged(ByVal sender As Object, ByVal
e As EventArgs) Handles Calendar1.SelectionChanged
Label1.Text = "you Selected:" +
Calendar1.SelectedDate.ToString("D")
End Sub
End Class
Output:
38
21. Write a program to show the use of state management in
asp.net.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<input id="text1" type="text" /><br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
</div>
</form>
</body>
</html>
Output:
39
22. Write a program to create placeholder in asp.net.
<%@ Page Language="vb" AutoEventWireup="false"
CodeBehind="WebForm1.aspx.vb" Inherits="PF.WebForm1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
username:<br />
<asp:textbox runat="server" ID="tbName"/><br />
e-mail:<br />
<asp:TextBox runat="server" ID="tbEmail" /><br />
<asp:Button ID ="Button1" runat ="server" Text="Submit" />
</asp:PlaceHolder>
</div>
</form>
</body>
</html>
Output:
40