1.
RAILWAYRESERVATIONUSINGHTMLCONTROLS
Aim:
To create a webpage to perform railway reservation.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtName
2. TextBox txtEmail
3. TextBox txtDate
4. DropdownList ddlSource
5. DropdownList ddlDestination
6. Button btnReserve
7. Label lblMessage
Coding:
public partial class_Default:[Link]
{
protectedvoidbtnReserve_Click(objectsender,EventArgse)
{
string name = [Link];
string email = [Link];
string source=[Link];
string destination=[Link];
string date = [Link];
if([Link](name)||[Link](email)||
[Link](source)||[Link](destination)||
[Link](date))
{
[Link]="Pleasefillallfields!";
}
else
{
[Link]=$"TicketReservedSuccessfully!\nName:{name}, From
{source}to{destination}on{date}";
}
}
}
2. FEEDBACKFORMUSINGHTMLCONTROLS
Aim:
To create a webpage to perform feedback form.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtName
2. TextBox txtEmail
1
3. TextBox txtComment
4. DropdownList ddlRate
5. Button btnSubmit
6. Label lblMessage
Coding:
public partial class Feedback:[Link]
{
protected void btnSubmit_Click(objectsender,EventArgse)
{
string name = [Link];
string email = [Link];
string rating=[Link];
string comments=[Link];
if ([Link](name) || [Link](email) ||
[Link](rating)||[Link](comments))
{
[Link]="⚠Pleasefillinallfields.";
}
else
{
[Link]=$"⬛Thankyou{name}!Yourfeedbackhasbeen recorded.\n" +
$"Rating:{rating}\nComments:{comments}";
}
}
}
3. LOGINFORMUSINGHTMLSERVERCONTROLS
Aim:
To create a webpage to perform loginform.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtUser
2. TextBox txtPass
3. Button btnLogin
4. Label lblMsg
Coding:
public partial class WebForm3:[Link]
{
protected voidb tnLogin_ServerClick(objectsender,EventArgse)
{
string username=[Link];
string password=[Link];
if(username=="admin"&& password=="12345")
{
2
[Link]="LoginSuccessful!";
[Link]["color"] = "green";
}
else
{
[Link]="InvalidUsernameorPassword";
[Link]["color"] = "red";
}
}
}
4. BOOKPURCHASEUSINGHTMLSERVERCONTROLS
Aim:
To create a webpage to purchase books online.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtName
2. TextBox txtBook
3. TextBox(Number) txtQty
4. TextBox(Number) txtPrice
5. Button btnBuy
6. Label lblResult
Coding:
public partial class WebForm4:[Link]
{
protected void btnBuy_ServerClick(objectsender,EventArgse)
{
string name=[Link];
string book = [Link];
int qty = Convert.ToInt32([Link]);
double price = [Link]([Link]);
double total = qty * price;
[Link]="Hello"+name+",youpurchased"
+qty+"copy(ies)of'"+book+ "'.
Total Price = ₹" + total;
}
}
5. FLIGHTRESERVATIONUSINGHTMLSERVERCONTROLS
Aim:
To create a webpage to perform flight reservation.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtName
3
2. TextBox txtBook
3. TextBox(Number) txtQty
4. TextBox(Number) txtPrice
5. Button btnBuy
6. Label lblResult
Coding:
public partial class WebForm5:[Link]
{
protected void btnBook_ServerClick(objectsender,EventArgse)
{
string name = [Link];
string fromCity=[Link];
string toCity = [Link];
string date = [Link];
int tickets = Convert.ToInt32([Link]);
double price = [Link]([Link]);
double total = tickets * price;
[Link]="Hello"+name+
",yourflightfrom"+fromCity+"to"+toCity+ " on " +
date + " is booked. " +
"TotalFare=₹"+total;
}
6. UGONLINEADMISSIONUSINGWEBFORMCONTROLS
Aim:
To create a webpage to perform ug online admission form.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtName
2. TextBox txtEmail
3. TextBox(Date) txtDOB
4. TextBox(Multiline) txtAddress
5. Label lblAddress
6. Dropdownlist ddlCourse
7. Radiobuttonlist rblGender
8. Label lblGender
9. Label lblCourse
10. Label lblName
11. Label lblEmail
12. Label lblDOB
13. Button btnSubmit
14. Label lblResult
4
Coding:
public partial class WebForm6:[Link]
{
protectedvoidbtnSubmit_Click(objectsender,EventArgse)
{
string name=[Link];
string email=[Link];
string dob = [Link];
string gender=[Link];
string course=[Link];
string address=[Link];
[Link]="ApplicationSubmittedSuccessfully!<br/>"+
"Name: " + name + "<br/>" +
"Email: " + email + "<br/>" +
"DOB: " + dob + "<br/>" +
"Gender:"+gender+"<br/>"+
"Course: " + course + "<br/>" +
"Address: " + address;
}
}
7. ARITHMETICOPERATIONS
Aim:
To create a web page to perform arithmetic operations.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtNum1
2. TextBox txtNum2
3. Label lblNum1
4. Label lblNum2
5. Button BtnAdd
6. Button BtnSub
7. Button BtnMul
8. Button BtnDiv
9. Label lblResult
Coding:
public partial class WebForm7:[Link]
{
protected void btnAdd_Click(object sender,EventArgs e)
{
inta=Convert.ToInt32([Link]);
intb=Convert.ToInt32([Link]);
int result = a + b;
[Link]="Addition="+result;
}
protected void btnSub_Click(object sender,EventArgse)
{
int a=Convert.ToInt32([Link]);
5
int b =Convert.ToInt32([Link]);
int result=a-b;
[Link]="Subtraction="+result;
}
protected void btnMul_Click(objectsender,EventArgse)
{
int a=Convert.ToInt32([Link]);
int b=Convert.ToInt32([Link]);
int result = a * b;
[Link]="Multiplication="+result;
}
protected void btnDiv_Click(objectsender,EventArgs e)
{
int a=Convert.ToInt32([Link]);
int b=Convert.ToInt32([Link]);
if (b != 0)
{
double result = (double)a / b;
[Link]="Division="+result;
}
else
{
[Link]="Cannotdividebyzero!";
}
}
}
8. CHECKTHEGIVENNUMBERISPOSITIVEORNEGATIVEOR
ZERO
Aim:
To create a webpage to check the given number is positive or negative or zero.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtNum
2. Button btnCheck
3. Label lblNum
4. Label lblResult
Coding:
public partial class WebForm8:[Link]
{
protected void btnCheck_Click(object sender,EventArgse)
{
int num=Convert.ToInt32([Link]);
if (num > 0)
{
[Link]=num+"isPositive.";
}
elseif(num<0)
{
[Link]=num+"isNegative.";
6
}
else
{
[Link]="ThenumberisZero.";
}
}
}
9. FINDTHELENGTHOFAGIVENSTRING
Aim:
To create a webpage to find the length of a given string.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtStr
2. Button btnFind
3. Label lblStr
4. Label lblResult
Coding:
public partial class WebForm9:[Link]
{
protected void btnFind_Click(objectsender,EventArgse)
{
stringstr=[Link];
int length =[Link];
[Link]="Length of the given string:"+length;
}
}
10. FINDTHESUMOF’N’NATURALNUMBERS
Aim:
To create a webpage to find the sum of ‘n’ natural numbers.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtN
2. Button btnSum
3. Label lblN
4. Label lblResult
Coding:
public partial class WebForm10:[Link]
{
protected void btnSum_Click(objectsender,EventArgse)
{
intn=Convert.ToInt32([Link]);
7
int sum = n * (n + 1) / 2;
[Link]="Sum of first"+n+"natural numbers="+sum;
}
}
11. CHANGINGBACKGROUNDCOLOURUSINGRADIOBUTTON
Aim:
To create a webpage to changing the background colour using radio button.
Controlsused:
[Link] ControlType Control Name
1. RadioButton rbred
2. RadioButton rbblue
3. RadioButton rbgreen
4. RadioButton rbyellow
5. HTMLBody Tag mybody
Coding:
public partial class BgColor:[Link]
{
protected void rbRed_CheckedChanged(object sender,EventArg se)
{
[Link]["background-color"]="red";
}
protected void rbGreen_CheckedChanged(object sender,EventArg se)
{
[Link]["background-color"]="green";
}
protected void rbBlue_CheckedChanged(object sender,EventArg se)
{
[Link]["background-color"]="blue";
}
protected void rbYellow_CheckedChanged(object sender,EventArg se)
{
[Link]["background-color"]="yellow";
}
}
12. RICHCONTROL-ADROTATOR
Aim:
To create a webpage to perform adrotator.
Controlsused:
[Link] ControlType Control Name
1. Adrotator Adrotator1
Coding:
8
<Advertisements>
<Ad>
<ImageUrl>[Link]</ImageUrl>
<NavigateUrl>[Link]
<AlternateText>Google Official Site</AlternateText>
<Impressions>30</Impressions>
</Ad>
<Ad>
<ImageUrl>[Link]</ImageUrl>
<NavigateUrl>[Link]
<AlternateText>Amazon India</AlternateText>
<Impressions>20</Impressions>
</Ad>
</Advertisements>
13. RICHCONTROL-CALENDAR
Aim:
To create a webpage to perform calendar.
Controlsused:
[Link] ControlType Control Name
1. Calendar Calendar1
2. Label lblDate
Coding:
public partial class WebForm13:[Link]
{
protected void Calendar1_SelectionChanged(objectsender,EventArgse)
{
[Link]="Youselected:"+[Link]();
}
}
14. FILEHANDLING
Aim:
To create a webpage to perform file handling.
Controlsused:
[Link] ControlType Control Name
1. Textbox txtContent
2. Label lblResult
3. Button btnWrite
4. Button btnRead
Coding:
publicpartialclassWebForm14:[Link]
{
protectedvoidbtnWrite_Click(objectsender,EventArgse)
{
string filepath=@"C:\file\[Link]";//Changepathifneeded
string content = [Link];
[Link](filepath, content);
[Link]="Filewrittensuccessfully!";
9
}
protected void btnRead_Click(objectsender,EventArgse)
{
string filepath=@"C:\file\[Link]";//Samepath if
([Link](filepath))
{
string content = [Link](filepath);
[Link]="FileContent:<br/>"+content;
}
else
{
[Link]="Filenotfound!";
}
}
}
15. VALIDATIONCONTROLS
Aim:
To create a webpage to perform validation control.
Controlsused:
[Link] ControlType Control Name
1. Textbox txtUser
2. Textbox txtPass
3. RequiredFieldValidator rfvUser
4. RequiredFieldValidator rfvPass
5. Label lblMsg
6. CompareValidator cvPass
7. Button btnSubmit
Coding:
public partial class WebForm15:[Link]
{
protected void btnSubmit_Click(objectsender,EventArgse)
{
if ([Link])
{
[Link]="Formsubmittedsuccessfully!";
}
else
{
[Link] = "Please correct the errors.";
[Link]=[Link];
}
}
}
1
0
16. DATABINDINGWITHDATACONTROLS
Aim:
To create a webpage to perform data binding with data controls.
Controlsused:
[Link] ControlType Control Name
1. GridView GridView1
2. SqlDataSource SqlDataSource1
Coding:
CREATETABLE[dbo].[students] (
[Id]INTNOTNULLPRIMARYKEY,
[name]NVARCHAR(50)NOTNULL,
[marks] INT NOT NULL
)
17. DATABASE OPERATIONS
Aim:
To create a webpage to perform database operations.
Controlsused:
[Link] ControlType Control Name
1. GridView GridView1
Coding:
public partial class GRALL:[Link]
{
string connStr =
[Link]["DataConnections"].ConnectionString;
protected void Page_Load(objectsender,EventArgse)
{
if(!IsPostBack)
BindGrid();
}
privatevoidBindGrid()
{
try
{
using(SqlConnectioncon=new SqlConnection(connStr))
{
SqlDataAdapterda=newSqlDataAdapter("SELECT*FROMusers",con); DataTable
dt = new DataTable();
[Link](dt);
[Link]=dt;
[Link]();
}
}
catch(SqlExceptionex)
1
1
{
[Link]("<b>SQLError:</b>"+[Link]);
}
catch(Exceptionex)
{
[Link]("<b>GeneralError:</b>"+[Link]);
}
}
protected void GridView1_RowEditing(object sender,
[Link] e)
{
[Link]=[Link];
BindGrid();
}
protected void GridView1_RowUpdating(object sender,
[Link] e)
{
int id = Convert.ToInt32([Link][[Link]].Value);
string name =
(([Link])[Link][[Link]].Cells[1].Controls[0]
).Text;
string email =
(([Link])[Link][[Link]].Cells[2].Controls[0]
).Text;
using(SqlConnectioncon=newSqlConnection(connStr))
{
stringquery="UPDATEUsersSETName=@Name,Email=@EmailWHERE Id=@Id";
SqlCommandcmd=newSqlCommand(query,con);
[Link]("@Name", name);
1
2
[Link]("@Email", email);
[Link]("@Id", id);
[Link]();
[Link]();
[Link]();
}
[Link]=-1;
BindGrid();
}
protected void GridView1_RowCancelingEdit(object sender,
[Link] e)
{
[Link]=-1;
BindGrid();
}
protectedvoidGridView1_RowDeleting(objectsender,GridViewDeleteEventArgse)
{
int userId = Convert.ToInt32([Link][[Link]].Values["Id"]);
using (SqlConnection conn = new SqlConnection(connStr))
{
SqlCommand cmd=new SqlCommand("DELETEFROMUsersWHEREId= @Id",
conn);
[Link]("@Id", userId);
[Link]();
[Link]();
1
3
18. IMPLEMENTTHEXMLCLASSES
Aim:
Tocreateawebpagetoperformimplementthexml classes.
Controlsused:
[Link] ControlType Control Name
1. GridView GridView1
2. Button btnAdd
3. Button btnUpdate
4. Button btnDelete
Coding:
public partial class WebForm16:[Link]
{
string filePath;
protected void Page_Load(objectsender,EventArgse)
{
filePath=[Link]("~/App_Data/[Link]"); if
(!IsPostBack)
{
//Iffiledoesn't exist,create it
if ()
{
CreateXml();
}
BindGrid();
}
}
private void CreateXml()
{
XmlDocument doc = new XmlDocument();
XmlElement root = [Link]("Students");
XmlElement student1=[Link]("Student");
[Link](CreateElement(doc, "Id", "1"));
[Link](CreateElement(doc,"Name","Dharani"));
[Link](CreateElement(doc, "Age", "19"));
XmlElement student2 = [Link]("Student");
[Link](CreateElement(doc, "Id", "2"));
[Link](CreateElement(doc, "Name", "Siva"));
[Link](CreateElement(doc, "Age", "21"));
[Link](student1);
[Link](student2);
[Link](root);
[Link](filePath);
}
1
4
private XmlElement CreateElement(XmlDocument doc,string name ,string innerText)
{
XmlElement element=[Link](name);
[Link] = innerText;
return element;
}
private void BindGrid()
{
DataSet ds = new DataSet();
[Link](filePath);
[Link]=ds;
[Link]();
}
protected void btnAdd_Click(objectsender,EventArgs e)
{
XmlDocument doc=newXmlDocument();
[Link](filePath);
XmlElement student = [Link]("Student");
[Link](CreateElement(doc, "Id", "4"));
[Link](CreateElement(doc,"Name","devi"));
[Link](CreateElement(doc, "Age", "23"));
[Link](student);
[Link](filePath);
BindGrid();
}
protected void btnUpdate_Click(objectsender,EventArgse)
{
XmlDocument doc=new XmlDocument();
[Link](filePath);
XmlNode node=[Link]("/Students/Student[Id='1']/Age"); if
(node != null) [Link] = "20";
[Link](filePath);
BindGrid();
}
protected void btnDelete_Click(objectsender,EventArgs e)
{
XmlDocument doc=new XmlDocument();
[Link](filePath);
XmlNode node=[Link]("/Students/Student[Id='3']");
if (node != null &&[Link] != null)
[Link](node);
[Link](filePath);
BindGrid();
}
1
5
19. [Link]
Aim:
To create a web page to perform ticket reservation.
Controlsused:
[Link] ControlType Control Name
1. TextBox txtName
2. Button btnReserve
3. TextBox txtFrom
4. TextBox txtTo
5. TextBox txtTickets
6. Label lblResults
7. Label lblName
8. Label lblFrom
9. Label lblTo
10. Label lblTickets
11. Label lblDate
12. Label lblClass
13. Calendar calDate
14. DropDownList ddlClass
Coding:
public partial class WebForm17:[Link]
{
protected void btnReserve_Click(objectsender,EventArgse)
{
string name=[Link];
string from = [Link];
string to = [Link];
string date=[Link]();
string tickets = [Link];
string travelClass = [Link];
[Link]="ReservationSuccessful!<br/>"+
"Name:"+name+"<br/>"+
"From: " + from + "<br/>" +
"To: " + to + "<br/>" +
"JourneyDate:"+date+"<br/>"+
"Tickets: " + tickets + "<br/>" +
"Class: " + travelClass;
}
}
1
6
20. [Link]
Aim:
To create a webpage to perform online examination.
Controlsused:
[Link] ControlType Control Name
1. RadioButtonList rbQ1
2. Button btnSubmit
3. RadioButtonList rbQ2
4. RadioButtonList rbQ3
5. Label lblQ1
6. Label lblQ2
7. Label lblQ3
8. Label lblResult
Coding:
public partial class OnlineExam:[Link]
{
protected void btnSubmit_Click(objectsender,EventArgse)
{
int score=0;
if([Link]!=null&&[Link]=="NewDelhi") score+
+;
if([Link]!=null&&[Link]=="Jupiter") score++;
if([Link]!=null&&[Link]=="12")
score++;
[Link]="You scored"+score+"out of 3.";
}
}
1
7