Practical File Of
ASP.NET
Submitted To:- Submitted By:-
Prof. Monika Singla Akshit Jindal
Class - B.C.A 3rd
Roll Number - 308381
Session 2023-24
INDEX
S.NO. PROGRAM NAME PAGE NO.
1. WRITE A SIMPLE PROGRAM USING C# 1
2. WRITE A PROGRAM TO SHOW 2
ARITHMETIC OPERATORS USING C#.
3. WRITE A PROGRAM TO SHOW 3
CONDITIONAL OPERATORS USING C#.
4. WRITE A PROGRAM RELATED TO 4
CONSTRUCTOR USING C#.
5. WRITE A PROGRAM RELATED TO 5
INHERITANCE USING C#.
6. Display the Information Using Label 6
Control.
7. Show the accepting user input using Textbox 7
Control.
8. Show the information using Checkbox 8-9
Control .
9. Show the use of Radio Button . 10-11
10 Show the use of Image Button Control . 12-13
11. Display the image using Image Control . 14
12. Show image mapping using Image Map 15
Control .
13. Show the Hyperlink Control . 16
14. Show the Required Field Validator Control . 17-18
15. Show the Range Validator Control . 19-20
16. Show the Compare Validator Control . 21-22
17. Show the Regular Expression Validator 23-24
Control .
18. Show the Validation Summary . 25-26
19. Show the Link Button Control. 27-28
20. Show the Link Button Control. 29-30
21. Show the Radio Button List Control. 31-32
22. Show the Check Box List Control in List 33
Control.
23. Show the Bulleted List Control in List 34
Control.
24. Show Calendar Control in Rich Web 35-36
Control.
25. Show the Ad Rotator in Rich Web Control. 37-38
26. Show the File Upload Control in Rich Web 39-40
Control.
OUTPUT:-
PAGE NO. 1
1. WRITE A PROGRAM USING C# .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace simple
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("\n Name: - Akshit Jindal");
Console.WriteLine("\n Roll No: - 231103046");
}
}
}
OUTPUT:-
PAGE NO. 2
2. WRITE A PROGRAM TO SHOW ARITHMETIC
OPERATORS USING C#.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace arithemtic
{
internal class Program
{
static void Main(string[] args)
{
int a, b, add, mul, sub, div, mod;
Console.WriteLine("\n Name: - Akshit Jindal");
Console.WriteLine("\n Roll No: - 231103046");
Console.Write("\n Enter the value of a = ");
a=Convert.ToInt32(Console.ReadLine());
Console.Write("\n Enter the value of b = ");
b=Convert.ToInt32(Console.ReadLine());
add=a+b;
mul = a * b;
sub = a - b;
div = a / b;
mod = a % b;
Console.WriteLine("\n Addition = "+add);
Console.WriteLine("\n Subtraction = "+sub);
Console.WriteLine("\n Multiplication = "+mul);
Console.WriteLine("\n Division = "+div);
Console.WriteLine("\n Modulus = "+mod);
}
}
}
OUTPUT:-
PAGE NO. 3
3. WRITE A PROGRAM TO SHOW CONDITIONAL
OPERATORS USING C#.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace relationalop
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("\n Name:-Akshit Jindal");
Console.WriteLine("\n Roll no:- 231103046");
int a, b;
Console.Write("\n Enter the value of a = ");
a=Convert.ToInt32(Console.ReadLine());
Console.Write("\n Enter the value of b = ");
b=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\n A < B (a is smaller then b) = " + (a < b));
Console.WriteLine("\n A > B (a is greater then b) = " + (a > b));
Console.WriteLine("\n A >= B (a is greater then equal to b) = " + (a >= b));
Console.WriteLine("\n A <= B (a is less then equal to b) = " + (a <= b));
Console.WriteLine("\n A == B (a is equal to b) = " + (a == b));
Console.WriteLine("\n A != B (a is not equal to b)= " + (a != b));
}
}
}
OUTPUT:-
PAGE NO. 4
4. WRITE A PROGRAM RELATED TO CONSTRUCTOR
USING C#.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace cosnstructor
{
class React
{
double length, breath, area;
public React(double a,double b)
{
length = a;
breath = b;
area = length * breath;
}
public void display()
{
Console.WriteLine("\n Length = " + length);
Console.WriteLine("\n Breath = " + breath);
Console.WriteLine("\n Area of reactangle = " + area);
}
}
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("\n Name: - Akshit Jindal");
Console.WriteLine("\n Roll No: - 231103046");
React re = new React(20.20, 3.26);
re.display();
}
}
}
OUTPUT:-
PAGE NO. 5
5. WRITE A PROGRAM RELATED TO INHERITANCE
USING C#.
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace inheritance
{
class A
{
public void show()
{
Console.WriteLine("\n Base class");
}
}
class B : A
{
public void getdata()
{
Console.WriteLine("\n Derived class");
}
}
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("\n Name: - Akshit Jindal");
Console.WriteLine("\n Roll No: - 231103046");
B ob= new B();
ob.getdata();
ob.show();
}
}
}
OUTPUT:-
PAGE NO. 6
6. Display the Information Using Label Control.
Design View:-
OUTPUT:-
PAGE NO. 7
7. Show the accepting user input using Textbox Control.
Design View:-
OUTPUT:-
PAGE NO. 8
8. Show the information using Checkbox Control .
Design View:-
PAGE NO. 9
Source Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CheckBox : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (lbl_dan.Checked == true)
lbl_show.Text = "Dancing";
if (lbl_sin.Checked== true)
lbl_show.Text =lbl_show.Text+","+ "Singing";
if (lbl_ball.Checked== true)
lbl_show.Text = lbl_show.Text + "," + "FootBall";
if (lbl_read.Checked== true)
lbl_show.Text = lbl_show.Text + "," + "Reading";
if (lbl_o.Checked== true)
lbl_show.Text = lbl_show.Text + "," + "Others";
}
}
OUTPUT:-
PAGE NO. 10
9. Show the use of Radio Button .
Design view:-
PAGE NO. 11
Source Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Form_file
{
public partial class WebForm1 :System.Web.UI.Page
{
protected void Button1_Click1(object sender, EventArgs e)
{
if(al.Checked==true)
{
show.Text = "C is Correct Answer";
}
else
{
show.Text = "You Choose Wrong Answer" + " " +
", C is Correct Answer";
}
}
}
}
OUTPUT:-
PAGE NO. 12
10. Show the use of Image Button Control .
Design View:-
PAGE NO. 13
Source Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace newform
{
public partial class WebForm1 :System.Web.UI.Page
{
protected void ImageButton1_Click1(object sender, ImageClickEventArgs
e)
{
show.Text = "Submitted....";
id.Text = "User ID : - " + userid.Text;
pass.Text = "Password : - " + passtxt.Text;
}
}
}
OUTPUT:-
PAGE NO. 14
11. Display the image using Image Control .
Design View:-
OUTPUT:-
PAGE NO. 15
12. Show image mapping using Image Map Control .
Design View:-
OUTPUT:-
PAGE NO. 16
13. Show the Hyperlink Control .
Design View:-
OUTPUT:-
PAGE NO. 17
14. Show the Required Field Validator Control .
Design View:-
PAGE NO. 18
Source Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class RequiredFieldValidator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
show.Text = "--- Preview ---";
stname_txt.Text = "Student Name : - " + st_txt.Text;
ph_txt.Text = "Phone No. : - " + phn_txt.Text;
}
}
OUTPUT:-
PAGE NO. 19
15. Show the Range Validator Control .
Design View:-
PAGE NO. 20
Source Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class RangeValidator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
show.Text = "--- Preview ---";
stname.Text = "Student Name : - " + stname_txt.Text;
age.Text = "Age : - " + age_txt.Text;
}
}
OUTPUT:-
PAGE NO. 21
16. Show the Compare Validator Control .
Design View:-
PAGE NO. 22
Source Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CompareValidator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
show.Text = "--- Preview ---";
stname.Text = "Student Name : - " + stname_txt.Text;
show_pass.Text = "Password : - " + pass_txt.Text;
}
}
OUTPUT:-
PAGE NO. 23
17. Show the Regular Expression Validator Control .
Design View:-
PAGE NO. 24
Source Code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class RegularExpressionValidator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
show.Text = "Submitted...";
show_email.Text = "Email ID : - " + email_txt.Text;
show_pass.Text = "Password : - " + pass_txt.Text;
}
}
OUTPUT:-
PAGE NO. 25
18. Show the Validation Summary .
Design View:-
PAGE NO. 26
Source Code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ValidationSummary : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
show.Text = "Submitted...";
show_email.Text = "Email ID : - " + email_txt.Text;
show_pass.Text = "Password : - " + pass_txt.Text;
}
}
OUTPUT:-
PAGE NO. 27
19. Show the Link Button Control.
Design View:-
PAGE NO. 28
Source Code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class LinkButtonControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
show_user.Text = "User ID: - " + user_txt.Text;
show_pass.Text = "Password: - " + pass_txt.Text;
}
}
OUTPUT:-
PAGE NO. 29
20. Show the Drop-Down List Control in List Control.
Design View: -
PAGE NO. 30
Source Code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class DropDownListControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
show_city.Text = "City Name : " + City_list.Text;
}
protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{
}
}
OUTPUT:-
PAGE NO. 31
21. Show the Radio Button List Control in List Control.
Design View: -
PAGE NO. 32
Source Code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class RadioButtonListControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
show_course.Text = "Selected Course : " + course.Text;
}
}
OUTPUT:-
PAGE NO. 33
22. Show the Check Box List Control in List Control.
Design View: -
OUTPUT:-
PAGE NO. 34
23. Show the Bulleted List Control in List Control.
Design View: -
OUTPUT:-
PAGE NO. 35
24. Show Calendar Control in Rich Web Control.
Design View: -
PAGE NO. 36
Source Code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Calendar : System.Web.UI.Page
{
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
DOB.Text = Calendar1.SelectedDate.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
show_dob.Text = "Date Of Birth : " + Calendar1.SelectedDate.ToString();
Calendar1.Visible = false;
}
}
OUTPUT:-
PAGE NO. 37
25. Show the Ad Rotator in Rich Web Control.
Design View: -
PAGE NO. 38
Source Code: -
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>Spotify.jpg</ImageUrl>
<NavigateUrl>https://open.spotify.com/</NavigateUrl>
<AlternateText>Spotify Image is not Available</AlternateText>
<Impressions>20</Impressions>
<Keyword>Spotify</Keyword>
</Ad>
<Ad>
<ImageUrl>ChatGpt.jpg</ImageUrl>
<NavigateUrl>https://chat.openai.com/</NavigateUrl>
<AlternateText>ChatGpt Image is not Available</AlternateText>
<Impressions>15</Impressions>
<Keyword>ChatGpt</Keyword>
</Ad>
<Ad>
<ImageUrl>Youtube.jpg</ImageUrl>
<NavigateUrl>https://www.youtube.com/</NavigateUrl>
<AlternateText>Youtube Image is not Available</AlternateText>
<Impressions>10</Impressions>
<Keyword>Youtube</Keyword>
</Ad>
</Advertisements>
OUTPUT:-
PAGE NO. 39
26. Show the File Upload Control in Rich Web Control.
Design View: -
PAGE NO. 40
Source Code: -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
{
namespace WebApplication5
{
public partial class WebForm1 :System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
protected void Button1_Click(object sender, EventArgs e)
{
if(file_upload.HasFile)
{
string s = Server.MapPath("~/Pictures");
s = s + "\\" + file_upload.FileName;
file_upload.SaveAs(s);
show_pic.Text = "Photo Uploaded Successfully";
}
else
{
show_pic.Text = "Please Upload Your Photo!";
}
}
}
}