Asp PDF
Asp PDF
Asp PDF
NET WITH C#
TYBSC-IT (SEM V)
T.Y.B.Sc. I.T.
SEMESTER V
ASP.NET with C#
LAB Manual
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
ASP.NET WITH C#
TYBSC-IT (SEM V)
ASP.NET WITH C#
TYBSC-IT (SEM V)
OUTPUT:
Enter Student Id:0001
Enter Student name : Prachit
Enter Course name : MSCit
Enter date of birth
Enter day(1-31):29
Enter month(1-12):9
Enter year:1995
Enter Student Id:0002
Enter Student name : Aniket
Enter Course name : Bscit
Enter date of birth
Enter day(1-31):4
Enter month(1-12):3
Enter year:1996
Enter Student Id:0003
Enter Student name : Prathamesh
Enter Course name : BMS
Enter date of birth
Enter day(1-31):9
Enter month(1-12):8
Enter year:2000
Enter Student Id:0004
Enter Student name : Sumit
Enter Course name :MScet
Enter date of birth
Enter day(1-31):25
Enter month(1-12):5
Enter year:1994
Enter Student Id : 0005
Enter Student name : Zaid
Enter Course name : BCOM
Enter date of birth
Enter day(1-31):6
Enter month(1-12):7
Enter year:1993
Student's List
Student ID : 0001
Student name : Prachit
Course name : MSCit
Date of birth(dd-mm-yy) : 29-9-1995
Student ID : 0002
Student name : Aniket
Course name : Bscit
Date of birth(dd-mm-yy) : 4-3-1996
Student ID : 0003
Student name : Prathamesh
Course name : BMS
Date of birth(dd-mm-yy) : 9-8-2000
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
ASP.NET WITH C#
TYBSC-IT (SEM V)
Student ID : 0004
Student name : Sumit
Course name : MScet
Date of birth(dd-mm-yy) : 25-5-1994
Student ID : 0005
Student name : Zaid
Course name : BCOM
Date of birth(dd-mm-yy) : 6-7-1993
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
10
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
11
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE -2:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int row, sp, col;
for (row = 1; row <= 5; row++)
{
for (sp = 1; sp <= 5 - row; sp++)
{
Console.Write(' ');
}
for (col = 1; col <= row; col++)
{
Console.Write(col);
}
Console.WriteLine();
}
}}}}
OUTPUT:
1
12
123
1234
12345
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
12
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE -3:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int row, sp, col,revcol;
for (row = 1; row <= 5; row++)
{
for (sp = 1; sp <= 5 - row; sp++)
{
Console.Write(' ');
}
for (col = 1; col <= row; col++)
{
Console.Write(col);
}
for (revcol = col - 2; revcol >= 1; revcol--)
{
Console.Write(revcol);
}
Console.WriteLine();
}
}
}
}
OUTPUT:
1
121
12321
1234321
123454321
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
13
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE-4:
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int row, sp, col, revcol;
for (row = 1; row <= 5; row++) {
for (sp = 1; sp <= 5 - row; sp++)
{
Console.Write(' ');
}
for (col = 1; col <= row; col++)
{
Console.Write(col);
}
for (revcol = col - 2; revcol >= 1; revcol--)
{ Console.Write(revcol); }
Console.WriteLine();
}
for (row = 4; row >= 1; row--) {
for (sp = 1; sp <= 5 - row; sp++)
{
Console.Write(' ');
}
for (col = 1; col <= row; col++)
{
Console.Write(col);
}
for (revcol = col - 2; revcol >= 1; revcol--)
{ Console.Write(revcol); }
Console.WriteLine();
} }} }
OUTPUT:
1
121
12321
1234321
123454321
1234321
12321
121
1
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
14
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE-5:
using System;
namespace pattern
{
class Program
{
static void Main(string[] args)
{
int row, col,sp,reverse;
for (row = 1; row <= 5; row++)
{
for (sp = 1; sp <= 5 - row; sp++)
Console.Write(" ");
for (col = 1; col <= row; col++)
if (col == 1)
Console.Write("*");
else
Console.Write(" ");
for (reverse = col - 2; reverse >= 1; reverse--)
if (reverse == 1)
Console.Write("*");
else
Console.Write(" ");
Console.WriteLine();
}
for (row = 4; row >=1; row--)
{
for (sp = 1; sp <= 5 - row; sp++)
Console.Write(" ");
for (col = 1; col <= row; col++)
if (col == 1)
Console.Write("*");
else
Console.Write(" ");
for (reverse = col - 2; reverse >= 1; reverse--)
if (reverse == 1)
Console.Write("*");
else
Console.Write(" ");
Console.WriteLine();
}
}}}
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
15
ASP.NET WITH C#
TYBSC-IT (SEM V)
*
**
* *
* *
*
*
* *
* *
**
*
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
16
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
17
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
18
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
19
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
20
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
21
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
22
ASP.NET WITH C#
TYBSC-IT (SEM V)
OUTPUT:
Enter name and post:Prachit
HOD
Enter name and post:Sumit
PM
Enter name and post:Aniket
HOD
Enter name and post:Prathamesh
PM
Enter name and post:Zaid
CA
Name
Post
Prachit
HOD
Aniket
HOD
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
23
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
24
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
25
ASP.NET WITH C#
TYBSC-IT (SEM V)
26
ASP.NET WITH C#
TYBSC-IT (SEM V)
surface_area = int.Parse(Console.ReadLine());
}
public void showdata()
{
base.showdata();
Console.WriteLine("Height : " + height);
Console.WriteLine("Surface Area : " + surface_area);
}}}
Program.cs
using System;
namespace SingleInheritance
{
class Program
{
static void Main(string[] args)
{
Table t1 = new Table();
t1.getdata();
t1.showdata();
}}}
OUTPUT:
Enter material : wood
Enter price : 1220
Enter height: 35
Enter surface area: 26
Material : wood
Price : 1220
Height : 35
Surface Area : 26
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
27
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
28
ASP.NET WITH C#
TYBSC-IT (SEM V)
OUTPUT:
Enter basic salary : 52000
Enter travelling allowance : 3000
Basic salary : 52000
Dearness allowence : 9000
Housing rent allowence : 6000
Travelling allowence : 3000
Gross Salary : 70000
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
29
ASP.NET WITH C#
TYBSC-IT (SEM V)
Class : Employee
name, basic_sal()
Class : salary
Disp_sal(),HRA
CODE:
Gross.cs
using System;
namespace MultipleInheritance
{
interface Gross
{
int ta
{
get;
set;
}
int da
{
get;
set;
}
int GrossSal();
}}
Employee.cs
using System;
namespace MultipleInheritance
{
class Employee
{
string name;
public Employee(string name)
{ this.name = name; }
public int BasicSal(int basicSal)
{
return basicSal; }
public void ShowData()
{
Console.WriteLine("Name : " + name);
}}}
Salary.cs
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
30
ASP.NET WITH C#
TYBSC-IT (SEM V)
using System;
namespace MultipleInheritance
{
class Salary:employee,Gross
{
int hra;
public Salary(string name, int hra):base(name)
{ this.hra = hra; }
public int ta
{
get {return S_ta; }
set { S_ta = value; }
}
private int S_ta;
public int da
{
get { return S_da; }
set { S_da = value; }
}
private int S_da;
public int GrossSal()
{
int gSal;
gSal = hra + ta + da + BasicSal(15000);
return gSal;
}
public void dispSal()
{ base.ShowData();
Console.WriteLine("Gross Sal : " + GrossSal());
}}}
Program.cs
using System;
namespace MultipleInheritance
{
class Program
{
static void Main(string[] args)
{
Salary s = new Salary("Prachit", 35000);
s.da = 20000;
s.ta = 30000;
s.dispSal();
}}}
OUTPUT:
Name :Prachit
Gross Sal :100000
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
31
ASP.NET WITH C#
TYBSC-IT (SEM V)
Programmer
Manager
CODE:
Employee.cs
using System;
namespace HeirarchicalInheritance
{
class employee
{
public virtual void display()
{
Console.WriteLine("Display of employee class called ");
}}}
Programmer.cs
using System;
namespace HeirarchicalInheritance
{
class Programmer:employee
{
public void display()
{
Console.WriteLine(" Display of Programmer class called ");
}}}
Manager.cs
using System;
namespace HeirarchicalInheritance
{
class Manager
{
public void display()
{
Console.WriteLine("Display of manager class called ");
}}}
Program.cs
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
32
ASP.NET WITH C#
TYBSC-IT (SEM V)
using System;
namespace HeirarchicalInheritance
{
class Program
{
static void Main(string[] args)
{
Programmer objProgrammer;
Manager objManager;
Console.Write("Whose details you want to use to see \n 1.Programmer \n
2.Manager");
int choice=int.Parse(Console.ReadLine());
if(choice==1)
{
objProgrammer=new Programmer();
objProgrammer.display();
}
else if(choice==2)
{
objManager=new Manager();
objManager.display();
}
else
{
Console.WriteLine("Wrong choice entered");
}}}}
OUTPUT:
Whose details you want to use to see
1.Programmer
2.Manager1
Display of Programmer class called
Whose details you want to use to see
1.Programmer
2.Manager2
Display of manager class called
Whose details you want to use to see
1.Programmer
2.Manager6
Wrong choice entered
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
33
ASP.NET WITH C#
TYBSC-IT (SEM V)
34
ASP.NET WITH C#
TYBSC-IT (SEM V)
}
public int getMarks1()
{
return marks1;
}
public int getMarks2()
{
return marks2;
}
public void dispaly()
{
base.display();
Console.WriteLine("Marks1: " + marks1);
Console.WriteLine("Marks2: " + marks2);
}}}
Student.cs
using System;
namespace multilevelinheritance
{
class student
{
int roll_no;
string name;
public student(int roll_no, string name)
{
this.roll_no = roll_no;
this.name = name;
}
public student() { }
public void display()
{
Console.WriteLine("Roll no: " + roll_no);
Console.WriteLine("Name: " + name);
}}}
Program.cs
using System;
namespace multilevelinheritance
{
class Program
{
static void Main(string[] args)
{
Result r1 = new Result(101, "Prachit", 50, 70);
r1.display();
}}}
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
35
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
36
ASP.NET WITH C#
TYBSC-IT (SEM V)
37
ASP.NET WITH C#
TYBSC-IT (SEM V)
}
public void display()
{
td[0]();
td[1]();
td[2]();
}
}}
Program.cs
using System;
namespace TrafficDelegateExample
{
class Program
{
static void Main(string[] args)
{
TrafficSignal ts = new TrafficSignal();
ts.IdentifySignal();
ts.display();
}}}
OUTPUT:
Yellow light signals to get ready
Green light signals to go
Red light signals to stop
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
38
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
39
ASP.NET WITH C#
TYBSC-IT (SEM V)
PROPERTIES TABLE:
Control
Label1
TextBox
Button
Label2
Property
Text
ID
ID
Text
ID
Text
ID
Value
Enter Number
lblnum1
getNum
Check
btncheck
Result
lblnum2
CODE:
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PalindromeCheck
{
public partial class PalindromeNumberCheck : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btncheck_Click(object sender, EventArgs e)
{
int num = int.Parse(getNum.Text);
int n, rev = 0, d;
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
40
ASP.NET WITH C#
TYBSC-IT (SEM V)
n = num;
while (n > 0)
{
d = n % 10;
n = n / 10;
rev = rev * 10 + d;
}
if (rev == num)
lblnum2.Text = lblnum2.Text + num + " is a Palindrome number.";
else
lblnum2.Text = lblnum2.Text + num + " is not a Palindrome number.";
}}}
BROWSER OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
41
ASP.NET WITH C#
TYBSC-IT (SEM V)
PROPERTIES TABLE:
Control
Label1
Checkbox1
Checkbox2
Checkbox3
RadioButton1
RadioButton2
RadioButton3
Label2
Button
Label3
Property
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
Value
lbl1
Enter Name
chkbold
BOLD
chkitalic
ITALIC
chkunderline
UNDERLINE
rbred
RED
rbgreen
GREEN
rbpink
PINK
txtmessage
Enter Message
btndisplay
Display
lblDisplay
Label3
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
42
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
using System;
namespace DisplayMessage
{
public partial class DisplayTheMessage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btndisplay_Click(object sender, EventArgs e)
{
if (chkbold.Checked == true)
lblDisplay.Font.Bold = true;
else
lblDisplay.Font.Bold = false;
if (chkitalic.Checked == true)
lblDisplay.Font.Italic = true;
else
lblDisplay.Font.Italic = false;
if (chkunderline.Checked == true)
lblDisplay.Font.Underline = true;
else
lblDisplay.Font.Underline = false;
if (rbred.Checked == true)
lblDisplay.ForeColor = System.Drawing.Color.Red;
else if(rbgreen.Checked == true)
lblDisplay.ForeColor = System.Drawing.Color.Green;
else if (rbpink.Checked == true)
lblDisplay.ForeColor = System.Drawing.Color.Pink;
lblDisplay.Text = "Name:" + txtName.Text + "<br/>" + "Message:" +
txtMessage.Text;
}}}
BROWSER OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
43
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
44
ASP.NET WITH C#
TYBSC-IT (SEM V)
PROPERTIES TABLE:
CODE:
using System;
namespace list
{
public partial class listselect : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdd_Click(object sender, EventArgs e)
{
int i;
for (i = 0; i < lstEmployee.Items.Count; i++)
{
if (lstEmployee.Items[i].Selected == true)
txtEmployee.Text += lstEmployee.Items[i].Text + "\n";
}
}}}
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
45
ASP.NET WITH C#
TYBSC-IT (SEM V)
BROWSER OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
46
ASP.NET WITH C#
TYBSC-IT (SEM V)
PROPERTIES TABLE:
Control
Label1
Property
ID
Text
RadioButton1
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
ID
Text
RadioButton2
RadioButton3
Label2
Label3
Label4
Button
Value
lbltxt1
How is the Book ASP.NET
with c# Vipul Prakashan
rdogood
Good
rdosatisfactory
Satisfactory
rdobad
Bad
lblgood
lblsatisfactory
lblbad
btnvote
Vote
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
47
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
using System;
namespace feedback
{
public partial class feedbackselect : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnvote_Click(object sender, EventArgs e)
{
if (rdogood.Checked == true)
{
int goodCount;
if (ViewState["gcount"] != null)
goodCount = Convert.ToInt32(ViewState["gcount"]) + 1;
else
goodCount = 1;
ViewState["gcount"] = goodCount;
}
if (rdosatisfactory.Checked == true)
{
int satisfactoryCount;
if (ViewState["scount"] != null)
satisfactoryCount = Convert.ToInt32(ViewState["scount"]) + 1;
else
satisfactoryCount = 1;
ViewState["scount"] = satisfactoryCount;
}
if (rdobad.Checked == true)
{
int badCount;
if (ViewState["bcount"] != null)
badCount = Convert.ToInt32(ViewState["bcount"]) + 1;
else
badCount = 1;
ViewState["bcount"] = badCount;
}
int totalCount;
if (ViewState["count"] != null)
totalCount = Convert.ToInt32(ViewState["count"]) + 1;
else
totalCount = 1;
ViewState["count"] = totalCount;
double gper = (Convert.ToDouble(ViewState["gcount"]) /
Convert.ToDouble(ViewState["count"])) * 100.0f;
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
48
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
49
ASP.NET WITH C#
TYBSC-IT (SEM V)
PROPERTIES TABLE:
CODE:
using System;
namespace raw
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
int curr_cal, total_cal, total_items;
protected void Bcalories_Click(object sender, EventArgs e)
{
curr_cal = (Convert.ToInt32(txtfat.Text) * 9 + Convert.ToInt32(txtcarbo.Text) * 4 +
Convert.ToInt32(txtpro.Text) * 4);
lblcfc.Text = Convert.ToString(curr_cal);
lblnof.Text = Convert.ToString(total_cal);
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
50
ASP.NET WITH C#
TYBSC-IT (SEM V)
lbltc.Text = Convert.ToString(total_items);
}
protected void Bitems_Click(object sender, EventArgs e)
{
lblnof.Text = Convert.ToString(Convert.ToInt32(lblnof.Text) + 1);
}
protected void Btotalcalo_Click(object sender, EventArgs e)
{
lbltc.Text = Convert.ToString(Convert.ToInt32(lbltc.Text) +
Convert.ToInt32(lblcfc.Text));
}
}}
BROWSER OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
51
ASP.NET WITH C#
TYBSC-IT (SEM V)
PROPERTY TABLE :
Control
Label1
Label1
Label1
Label1
Label2
Label2
Label3
Label3
TextBox1
TextBox2
TextBox3
Button1
Button1
Property
ID
Text
BorderStyle
BackColor
ID
Text
ID
Text
ID
ID
ID
ID
Text
Value
lblRollNo
Enter Roll No.
Dotted
Coral
lblName
Enter Name
lblMarks
Enter Marks
txtRollNo
txtName
txtMarks
btnSubmit
Submit
CODE:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cssexample.aspx.cs"
Inherits="practical4css.cssexample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
52
ASP.NET WITH C#
TYBSC-IT (SEM V)
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Enter Roll No.:"
BorderStyle="Dotted" BackColor="Coral"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Enter Name:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label3" runat="server" Text="Enter Marks:"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
<asp:Button ID="Button2" runat="server" Text="Clear" />
</div>
</form>
</body>
</html>
BROWSER OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
53
ASP.NET WITH C#
TYBSC-IT (SEM V)
PROPERTY TABLE :
Control
Label1
Label1
Label1
Label1
Label2
Label2
Label2
Label3
Label3
Label3
TextBox1
TextBox1
TextBox2
TextBox2
TextBox3
TextBox3
Button1
Button1
Button1
Button2
Button2
Button2
Property
ID
Text
BorderStyle
BackColor
ID
Text
CssClass
ID
Text
CssClass
ID
CssClass
ID
CssClass
ID
CssClass
ID
Text
CssClass
ID
Text
CssClass
Value
lblRollNo
Enter Roll No.
Dotted
Coral
lblName
Enter Name
Common
lblMarks
Enter Marks
Common
txtRollNo
Txt Style
txtName
Txt Style
txtMarks
Txt Style
btnSubmit
Submit
btnStyle
btnClear
Clear
btnStyle
CODE:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
54
ASP.NET WITH C#
TYBSC-IT (SEM V)
Myformat.css
.BtnStyle
{
font-family:Times New Roman;
font-size:large;
font-weight:bold;
}
.TxtStyle
{
font-family:Georgia;
font-size:larger;
font-weight:400;
background-color:Maroon;
border:2px solid goldenrod;
}
.Common
{
background-color:Aqua;
color:Red;
font-family:Courier New;
font-size:20px;
font-weight:bolder;
}
Myformatting.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="cssexample.aspx.cs"
Inherits="practical4css.cssexample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Enter Roll No.:" BorderStyle="Dotted"
BackColor="Coral"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" CssClass="TxtStyle"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Enter Name:"
CssClass="Common"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" CssClass="TxtStyle"></asp:TextBox>
<br />
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
55
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
56
ASP.NET WITH C#
TYBSC-IT (SEM V)
PROPERTY TABLE :
Control
Label1
Label1
Label1
Property
ID
Text
CssClass
Value
lblBScIT
Welcome to BScIT
bk
Control
Label1
Label1
Label1
Property
ID
Text
CssClass
Value
lblBAF
Welcome to BMS
bk
Control
Label1
Label1
Label1
Property
ID
Text
CssClass
Value
lblBMS
Welcome to BAF
bk
CODE:
Myformat.css
.BtnStyle
{
font-family:Times New Roman;
font-size:large;
font-weight:bold;
}
.TxtStyle
{
font-family:Georgia;
font-size:larger;
font-weight:400;
background-color:Lime;
border:2px solid goldenrod;
}
.Common
{
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
57
ASP.NET WITH C#
TYBSC-IT (SEM V)
background-color:Aqua;
color:Red;
font-family:Courier New;
font-size:20px;
font-weight:bolder;
}
.bk
{
background-color:Lime;
}
BScIT.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BScIT.aspx.cs"
Inherits="cssExample.BScIT" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="MyFormat.css" />
</head>
<body text="Welcome to BScIT">
<form id="form1" runat="server">
<div class="bk">
<asp:Label ID="lblBScIT" runat="server" Text="Welcome to BscIT"></asp:Label>
</div>
</form>
</body>
</html>
BAF.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BAF.aspx.cs"
Inherits="cssExample.BAF" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="MyFormat.css" />
</head>
<body>
<form id="form1" runat="server">
<div class="bk">
<asp:Label ID="lblBAF" runat="server" Text="Welcome to BAF"></asp:Label>
</div>
</form>
</body>
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
58
ASP.NET WITH C#
TYBSC-IT (SEM V)
</html>
BMS.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BMS.aspx.cs"
Inherits="cssExample.BMS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="MyFormat.css" />
</head>
<body>
<form id="form1" runat="server" class="bk">
<asp:Label ID="lblBMS" runat="server" Text="Welcome to BMS"></asp:Label>
</form>
</body>
</html>
CSSExample1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CSSExample1.aspx.cs"
Inherits="cssExample.CSSExample1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="MyFormat.css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblRollNo" runat="server" Text="Enter Roll No. :"
BorderStyle="Dotted" BackColor="Coral"></asp:Label>
&nbs
p;
<asp:TextBox ID="txtRoll" runat="server" CssClass="TxtStyle"></asp:TextBox>
<br />
<br />
<asp:Label ID="lblName" runat="server" Text="Enter Name :"
CssClass="Common"></asp:Label>
<asp:TextBox ID="txtName" runat="server" CssClass="TxtStyle"></asp:TextBox>
<br />
<br />
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
59
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
60
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
61
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
62
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
myformating.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="myformatting.aspx.cs"
Inherits="WebApplication1.myformatting" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="MyFormat.css" />
<style type="text/css">
h1,h2,h3{color:Blue; font-family:Agency FB;}
</style>
</head>
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
63
ASP.NET WITH C#
TYBSC-IT (SEM V)
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Enter Roll No.:" BorderStyle="Dotted"
BackColor="Coral"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" CssClass="TxtStyle"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Enter Name:"
CssClass="Common"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" CssClass="TxtStyle"></asp:TextBox>
<br />
<asp:Label ID="Label3" runat="server" Text="Enter Marks:"
CssClass="Common"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" CssClass="TxtStyle"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" CssClass="BtnStyle" />
<asp:Button ID="Button2" runat="server" Text="Clear" CssClass="BtnStyle" />
<h1><a href="bscit.aspx"</a>Bsc IT</h1>
<h2><a href ="baf.aspx"</a>BAF</h2>
<h3><a href ="bms.aspx"</a>BMS</h3>
<a href="http://www.vsit.edu.in/">
Contact us</a>
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
BROWSER OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
64
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
65
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
myformatting.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="myformatting.aspx.cs"
Inherits="WebApplication1.myformatting" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="MyFormat.css" />
<style type="text/css">
h1,h2,h3{color:Blue; font-family:Agency FB;}
A:link{color:Red;}
A:visited{color:Green;}
A:active{color:Orange;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Enter Roll No.:" BorderStyle="Dotted"
BackColor="Coral"></asp:Label>
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
66
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
67
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
ValidateControlForm.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ValidationControl
{
public partial class ValidationControlForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
68
ASP.NET WITH C#
TYBSC-IT (SEM V)
}
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
string str = args.Value;
args.IsValid = false;
if (str.Length < 7 || str.Length > 20)
{
return;
}
bool capital = false;
foreach (char ch in str)
{
if (ch >= 'A' && ch <= 'Z')
{
capital = true;
break;
}
}
if (!capital)
return;
bool digit = false;
foreach (char ch in str)
{
if (ch >= '0' && ch <= '9')
{
digit = true;
break;
}
}
if (!digit)
return;
args.IsValid = true;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
}
}}
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
69
ASP.NET WITH C#
TYBSC-IT (SEM V)
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
70
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
71
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
Web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~\" title="Local bank of india" description="Online Banking">
<siteMapNode url="default.aspx" title="Home" description="Go to the homepage" />
<siteMapNode url="about.aspx" title="About Us" description="About us"/>
<siteMapNode url="statistics.aspx" title="Statistics" description="Statistics">
<siteMapNode url="data.aspx" title="Data Releases" description="Data Releases"/>
<siteMapNode url="database.aspx" title="Database on Indian Economy"
description="Economy of India"/>
<siteMapNode url="service.aspx" title="Service" description="Service Information"/>
</siteMapNode>
<siteMapNode url="publications.aspx" title="Publications" description="Publications">
<siteMapNode url="annual.aspx" title="Annual" description="Annual"/>
<siteMapNode url="monthly.aspx" title="Monthly" description="Monthly"/>
<siteMapNode url="reports.aspx" title="Reports" description="Reports"/>
</siteMapNode>
</siteMapNode>
</siteMap>
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
72
ASP.NET WITH C#
TYBSC-IT (SEM V)
OUTPUT: (sitemap)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
73
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
74
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
75
ASP.NET WITH C#
TYBSC-IT (SEM V)
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
76
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
LoginModule.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
77
ASP.NET WITH C#
TYBSC-IT (SEM V)
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class LoginModule : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSignUp_Click(object sender, EventArgs e)
{
SqlDataSource1.InsertParameters["Username"].DefaultValue = txtUserName.Text;
SqlDataSource1.InsertParameters["Password"].DefaultValue = txtPassword.Text;
SqlDataSource1.Insert();
lblResult.Text = "User Added";
}
}
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
78
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
79
ASP.NET WITH C#
TYBSC-IT (SEM V)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class LoginModule : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSignUp_Click(object sender, EventArgs e)
{
SqlDataSource1.InsertParameters["Username"].DefaultValue = txtUserName.Text;
SqlDataSource1.InsertParameters["Password"].DefaultValue = txtPassword.Text;
SqlDataSource1.Insert();
Textbox1.Text=;
Textbox2.Text=;
}
}
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
80
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
81
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
82
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
83
ASP.NET WITH C#
TYBSC-IT (SEM V)
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data.Linq;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
EmployeeDataContext dc = new EmployeeDataContext();
var query = from m in dc.EmployeeTables select m;
GridView1.DataSource = query;
GridView1.DataBind();
}
}
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
84
ASP.NET WITH C#
TYBSC-IT (SEM V)
DESIGN:
CODE:
student.xml
<?xml version="1.0" encoding="utf-8" ?>
<TYStudents>
<student>
<srollno>1</srollno>
<sname>swati</sname>
<saddress>Wadala</saddress>
<sfees>1000</sfees>
</student>
<student>
<srollno>2</srollno>
<sname>natasha</sname>
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
85
ASP.NET WITH C#
TYBSC-IT (SEM V)
<saddress>Dadar</saddress>
<sfees>3000</sfees>
</student>
</TYStudents>
Defaultst.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Xml.Linq;
using System.Web.UI.WebControls;
public partial class Defaultst : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
XDocument xmlDoc =
XDocument.Load(HttpContext.Current.Server.MapPath("student.xml"));
var studs = from s in xmlDoc.Descendants("student")
select s;
GridView1.DataSource = studs;
GridView1.DataBind();
}
}
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
86
ASP.NET WITH C#
TYBSC-IT (SEM V)
DESIGN:
CODE:
App_Code/Products.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
public class Products
{
public string PID { get; set; }
public string PName { get; set; }
public int PPrice { get; set; }
public int PWeight { get; set; }
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
87
ASP.NET WITH C#
TYBSC-IT (SEM V)
public Products()
{
} }
ProductForm.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ProductForm : System.Web.UI.Page
{
public List<Products> GetProdData()
{
return new List<Products> {
new Products { PID="P101", PName="Laptop", PPrice=25000 , PWeight=1500},
new Products { PID="P102", PName="Desktop", PPrice=22000 , PWeight=8000},
new Products { PID="P103", PName="Mouse", PPrice=500 , PWeight=250}
};
}
protected void Page_Load(object sender, EventArgs e)
{
var prod = GetProdData();
var query = from f in prod
orderby f.PName
select f;
this.GridView1.DataSource = query;
this.GridView1.DataBind();
}
}
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
88
ASP.NET WITH C#
TYBSC-IT (SEM V)
PRACTICAL NO. : 08
AIM: (A) For the web page created for the display OF Employee data change the
authentication mode to Windows
CODE:
<system.web>
<authentication mode=Windows>
<forms loginUrl=~/Prac8/EmployeeForm.aspx>
</authentication>
</system.web
Steps for changing the authentication mode
1. Open the website created for displaying the Employee data
2.From the solution Explorer window open the web.config file
3 .In the web.config file search the <system.web> xml tag and in <system.web> xml tag go
to authentication tag
4. Change the authentication mode to windows as given above.
AIM: (B) For the webpage created for the display of Student data change the authorization
mode so that only users who have logged in as VSIT will have the authority to aces the page
CODE:
<system.web>
<authentication>
<allow users=VSIT/>
<deny users = */>
</authentication>
</system.web>
Steps for changing the authorization
1. Open the website created for displaying the Student data
2. From the solution Explorer window open the web.config file
3. In the Web.config file search the <system.web> xml tag and in <system.web> xml tag go
to authentication tag
4. Change the coding in the tag as given above
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
89
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
90
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Data.SqlClient;
publicpartialclassajaxform : System.Web.UI.Page
{
protectedvoidPage_Load(object sender, EventArgs e)
{
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
SqlConnection con = newSqlConnection(@"Data Source=.\sqlexpress;Initial
Catalog=BreakingNews;Integrated Security=True");
con.Open();
SqlCommand com = newSqlCommand("select * from news", con);
SqlDataReaderdr = com.ExecuteReader();
while (dr.Read())
{
Label1.Text +=dr[1].ToString()+"<br>";
}
con.Close();
}
}
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
91
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
using System;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Data.SqlClient;
publicpartialclassajaxform : System.Web.UI.Page
{
protectedvoidPage_Load(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
SqlConnection con = newSqlConnection(@"Data Source=.\sqlexpress;Initial
Catalog=BreakingNews;Integrated Security=True");
con.Open();
SqlCommand com = newSqlCommand("select * from news", con);
SqlDataReaderdr = com.ExecuteReader();
while (dr.Read())
{
Label1.Text +=dr[1].ToString()+"<br>";
}
con.Close();
}
}
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
92
ASP.NET WITH C#
TYBSC-IT (SEM V)
Source Code:
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="ajaxform.aspx.cs"Inherits="aj
axform"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0
Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:ScriptManagerID="ScriptManager1"runat="server">
</asp:ScriptManager>
<br/>
<asp:UpdatePanelID="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:LabelID="Label1"runat="server"></asp:Label>
<br/>
<br/>
<asp:ButtonID="Button1"runat="server"Text="Breaking news"/>
<br/>
</ContentTemplate>
</asp:UpdatePanel>
<br/>
<br/>
<br/>
<asp:UpdateProgressID="UpdateProgress1"runat="server">
<ProgressTemplate>Work in progress</ProgressTemplate>
</asp:UpdateProgress>
<br/>
<br/>
</div>
</form>
</body>
</html>
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
93
ASP.NET WITH C#
TYBSC-IT (SEM V)
Output:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
94
ASP.NET WITH C#
TYBSC-IT (SEM V)
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
95
ASP.NET WITH C#
TYBSC-IT (SEM V)
CODE:
Default.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class Defaultswati1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Timer1_Tick(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data Source=.\sqlexpress;Initial
Catalog=BreakingNews;Integrated Security=True");
SqlDataReader dr = null;
conn.Open();
SqlCommand cmd = new SqlCommand("Select * from score", conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
Label1.Text += dr[0].ToString() + " " + dr[1].ToString() + " " + dr[2].ToString() +
"<br>";
}
conn.Close();
}
}
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
96
ASP.NET WITH C#
TYBSC-IT (SEM V)
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
97
ASP.NET WITH C#
TYBSC-IT (SEM V)
Source Code:
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_D
efault"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0
Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
</head>
<body>
<formid="form1"runat="server">
<div>
<scripttype="text/javascript">
$(document).ready(function () {
$("p").css("color", "Yellow");
$("h1,h2").css("color", "White");
$("p#intro").css("color", "Blue");
$("*").css("background-color", "Red");
});
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
98
ASP.NET WITH C#
TYBSC-IT (SEM V)
</script>
<asp:ScriptManagerID="Scrpitmanager1"runat="server">
<Scripts>
<asp:ScriptReferencePath="~/scrpits/jquery-1.11.3.js"/>
</Scripts>
</asp:ScriptManager>
<h1>This is Jquery example</h1>
<h2>This is Jquery heading</h2>
<p>First paragraph is all about introduction</p>
<p>Second paragraph having details about it</p>
<pid="intro">Third paragraph is with id intro</p>
</div>
</form>
</body>
</html>
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
99
ASP.NET WITH C#
TYBSC-IT (SEM V)
Source Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript"">
$(document).ready(function () {
$('p').hide(1000);
$('p').show(2000);
$('p').toggle(3000);
$('p').slideDown(4000);
$('p').slideUp(5000);
$('h1').animate({
opacity: 0.4, marginLeft: '50px', fontSize: '100px'
}, 8000);
});
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
100
ASP.NET WITH C#
TYBSC-IT (SEM V)
</script>
<asp:ScriptManager ID="Scriptmanager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/Scripts/jquery-1.11.3.js" />
</Scripts>
</asp:ScriptManager>
<p>First Paragraph</p>
<h1>First Heading</h1>
</div>
</form>
</body>
</html>
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
101
ASP.NET WITH C#
TYBSC-IT (SEM V)
Source Code:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
$(document).ready(function(){
$('h1').animate({
opacity: 0.4,marginLeft:'50px',fontSize:'100px'},8000);
});
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/script/jquery-1.11.3.js" /></Scripts></asp:ScriptManager>
<p>First paragraph</p>
<h1>First heading heading</h1>
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
102
ASP.NET WITH C#
TYBSC-IT (SEM V)
</div>
</form>
</body>
</html>
OUTPUT:
Prepared By: Prof. Sanjeela Sagar, VSIT and Prof. Pallavi Tawde, VSIT
103