ASP Practical File
ASP Practical File
ASP Practical File
BRANCH- CS&IT
SEMESTER- Vth
ACKNOWLEDGEMENT –
I would like to thank my teacher Mr Uday Ranjan Sir who gave me this
opportunity to work on this assignment (Lab Manual). I got to learn a lot from
this assignment about: -
1. Design web applications using ASP.NET.
2. ASP.NET controls in web applications.
3. Debug and deploy ASP.NET web applications
4. Create database driven ASP.NET web applications and web service
I would like to thank my dear friends who have been with me all the time.
INDEX
S_No Topic Page_No Remarks
01 Write a program using 4 to 5
RequiredFieldValidation in ASP.NET.
2
03 Write a program using Compare Validation 8 to 9
in ASP.NET to check the password entered
by the user is correct or not, if the
password is correct then page will be
submitted.
PRACTICAL NO.: 01
AIM :- Write a program using RequiredFieldValidation in ASP.NET.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace RequiredFieldValidation
3
{
public partial class requiredField : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
When we click submit button without entering the input Username is Required message will
be display.
4
When we take the input and submit it then page is submitted message will be display.
5
PRACTICAL NO.: 02
AIM :- Write a program using Regular Expression Validation in ASP.NET.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace RegularExpressionValidator
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
When we take wrong input/format then this type of validation will be occurred.
6
And if we take write input/format then page will be successfully submitted.
7
PRACTICAL NO.: 03
AIM: - Write a program using Compare Validation in ASP.NET to check the
password entered by the user is correct or not, if the password is correct then
page will be submitted.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace compareValidator
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
8
When the user take correct password
9
PRACTICAL NO. : 04
AIM :- Write a program using to validate the age entered by the user is between 1 to
120 by using range validation :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace rangeValidation1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
10
When user take right input :-
11
PRACTICAL NO. : 05
AIM :- Write a program to check the number is odd, i.e. display the message (Number must be odd)
by using custom validation :-
// Design Code
// JavaScript fn:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" lang="ja"> // JavaScript function
function IsOdd(source, args) {
if (args.Value == "") {
args.IsValid = false;
}
else {
if (args.Value % 2 == 0) {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
}
12
</script>
</head>
<body style="height: 235px; width: 1963px">
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Font-Bold="True" style="z-index: 1;
left: 11px; top: 9px; position: absolute" Text="Enter Number :"></asp:Label>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="txtNumber" Font-Bold="True" ForeColor="#CC0000" style="z-index: 1;
left: 384px; top: 25px; position: absolute" ClientValidationFunction="IsOdd">Number
must be odd</asp:CustomValidator>
<p>
&n
bsp;
<asp:Button ID="Button1" runat="server" Font-Bold="True" style="z-index:
1; left: 51px; top: 86px; position: absolute; width: 74px" Text="Submit"
OnClick="Button1_Click" />
<asp:TextBox ID="txtNumber" runat="server" style="z-index: 1; left:
201px; top: 12px; position: absolute; height: 35px; width: 143px"></asp:TextBox>
</p>
<p>
</p>
<p>
&n
bsp;
<asp:Label ID="lblDisplay" runat="server" Font-Bold="True" style="z-index:
1; left: 154px; top: 103px; position: absolute" ForeColor="#CC0000"></asp:Label>
</p>
</form>
</body>
</html>
// Exectution code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace evenCustom
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
13
When user take even number :-
14
PRACTICAL NO. : 06
AIM: Write programs using conditional statements and loops: Generate Fibonacci series.
CODE:
using System;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
int num1=0,num2=1,num3,num4,num,counter;
Console.Write ("Upto how many number you want fibonacci series:");
num=int.Parse(Console.ReadLine());
counter=3; Console.Write(num1+"\t"+num2);
while(counter<=num) { num3 = num1 + num2;
if (counter >= num) break; Console.Write("\t" + num3);
num1 = num2; num2 = num3;
counter++;
}
}
15
}
}
OUTPUT:
PRACTICAL NO. : 07
AIM: Write programs using conditional statements and loops: III) Test for prime numbers.
CODE:
using System;
namespace testprime
class Program
16
Console.Write("Enter number:");
num = int.Parse(Console.ReadLine());
if ((num % counter) == 0)
break;
if (num == 1)
else if(counter<(num/2))
else
OUTPUT:
17
PRACTICAL NO. : 08
18
CODE:
using System;
namespace reverseNumber
class Program
int num,actualnumber,revnum=0,digit,sumDigits=0;
int.Parse(Console.ReadLine());
actualnumber = num;
sumDigits=sumDigits+digit;
19
OUTPUT:
PRACTICAL NO. : 09
20
AIM: Write a program using function overloading to swap two integer numbers and swap
two float numbers.
CODE:
using System;
namespace swap
class Overloading
int t;
t = n;
n = m;
m = t;
float f;
f = f1;
f1 = f2;
f2 = f;
class program
21
static void Main(string[] args)
OUTPUT :-
PRACTICAL NO. : 10
AIM: Define a class „salary‟ which will contain member variable Basic, TA, DA, HRA.
Write a program using Constructor with default values for DA and HRA and calculate the
salary of employee.
22
CODE:
Salary.cs
using System;
namespace SalaryConstructure
class Salary
public Salary()
da = 9000;
hra = 6000;
int.Parse(Console.ReadLine());
ta = int.Parse(Console.ReadLine());
23
Console.WriteLine("Travelling allowence : " + ta);
Program.cs
using System;
namespace SalaryConstructure
class Program
s.getdata();
s.showdata();
OUTPUT:
24
Basic salary : 52000
25