Anda di halaman 1dari 10

Lab Manual

Visual Programming & Server Side Programming (Pr)


IT-316

Lab Instructions
Whether an experiment contains one or
several practicals /programs

Several
practicals / programs

Lab Teacher forms groups of the students based on

One
practical / program
All Students need to perform the
practical/program

Assign all practicals /programs among all groups

Teacher decides whether the completed practicals / programs can be appropriately described
using flow chart, algorithm, query statement, etc.
Teacher issues necessary instructions to the students for writing practicals / programs
accordingly

Students write experiments in practical files and get them signed by the lab teacher
Students make entries in the list of contents of the practical files and get them signed by
the lab teacher

Whether practical has been verified


and signed by the lab teacher?

If a student has not completed a practical, he/she is expected to complete it at his/her


own with the help of his/her fellow students in his/her hostel
The student completes the practical file and submits it to the concerned teacher in
his/her office or mail box on next working day

In case of an experiment containing several practicals, a lab teacher needs to think whether a
practical performed by the students in one group needs to be repeated by the other groups in lab on
the same day?
OR
A practical performed by the students in one group needs to be repeated as assignments to be
completed by the students of other groups in their hostels? Here, an assignment includes both
executing a program on computer and also writing the same in practical file.
OR
A practical performed by the students in one group needs to be repeated as assignments, only
writing practicals in their practical files, for the students of other groups in their hostels?
Teacher issues necessary instructions to the students accordingly.

Lab Manual
L T P
- - 3

Visual Programming & Server Side Programming (Pr)


IT- 316
Practical exam: 40
Sessional: 60

This lab manual is designed for three server side programming languages viz. php, python and
ASP.net. ASP.NET is the next generation ASP, it's not an upgraded version of ASP. ASP.NET
is an entirely new technology for server-side scripting. This lab manual focuses on different
aspects of these languages and each experiment is further explored into four to five variants.
Experiment 1 (Web forms in ASP)
I.

Write a program to display a feedback form. The different options for the list box must
be ASP-XML, DotNET, JavaPro and Unix, C, C++. When the Submit Form button is
clicked after entering the data, a message must be displayed.

II.

Write a simple ASP.NET program to display the following Web Controls:


1. A button with text click me. The button control must be in the center of
the form.
2. A label with a text hello
3. A checkbox.
The form name must be Web Controls.

III.

Write a program to display Welcome To Radiant in the form when the click button
is clicked. The form title must be ASP.NET.

IV.

Write a program that displays a button in green color and it should change into yellow
when the mouse moves over it.

V.

Write a program containing the following controls:


1. A ListBox
2. A Button
3. An Image
4. A Label
The listbox is used to list items available in a store. When the user clicks on an item in
the listbox, its image is displayed in the image control. When the user clicks the
button,the cost of the selected item is displayed in the control.

Experiment 2 (Validators in ASP)


I.

Write a program to get a user input such as the boiling point of water and test it to the
appropriate value using CompareValidator.

II.

Write a program that uses a textbox for a user input name and validate it for
RequiredField Validation.

III.

Write a program that gets user input such as the user name, mode of payment,
appropriate credit card.After the user enters the appropriate values the Validation button
must validates the values entered.

IV.

Declare one TextBox control, one Button control, one Label control, and one
RegularExpressionValidator control in an .aspx file. The submit() function checks if the
page is valid. If it is valid, it returns "The page is valid!" in the Label control. If it is not
valid, it returns "The page is not valid!" in the Label control. If validation fails, the text
"The zip code must be 5 numeric digits!" will be displayed in the
RegularExpressionValidator control.

V.

Check the length of the string in the TextBox using CustomValidator.


Experiment 3 (Databases in ASP)

I.

Create table CANDIDATE with the following


Column name
Ccode
Name
DOJ

Datatype
Int
Char(20)
Date

i) Insert following records into the table:


Code
Name
DOJ

1001
S.Raman
12-jun-97

1002
M.Sushil
12-nov-97

1003
Mohanyes
30-jul-97

ii) Order the records on the basis of senority of employees.


iii) Drop the table.

II.

Create table EMPLOYEE with the following columns and datatypes.


DeptID
Name
DOJ
Sal
Desig

Numeric
Varchar(20)
Datetime
Float
Varchar(20)

i) Insert following records into the table:


DeptID
Name
DOJ
Sal
Desig

D1
Amit Kapoor
27-feb-92
4
ASE

D2
Taruun Kathuria
1-oct-87
10
Manager

D3
Parth Desai
30-jul-94
45
CEO

ii) Change the candidate name from Amit Kapoor to Sarfaraz Yousuf in the first
record in EMPLOYEE table.
iii) Select Dept ID from table EMPLOYEE.
III.

Create table STUDENT with the following columns and datatypes.


Sid
Name
DOB
Addr
Contact

Alphanumeric
Varchar(20)
DateTime
Varchar(20)
Varchar(10)

Insert following records into the table:


Sid
Name
DOB
Addr
Contact

S1
Osho Juneja
28-jan-93
ABC
9000000000

S2
Nishant Sahni
1-oct-92
XYZ
8000000000

S3
Sanya Dua
30-jul-94
PQR
7800000000

i) Select records from table where age>22.[Use DOB for age calculation].
ii) Count the record in the table.
iii) Display records of the table order by DOB.
3

Experiment 4 (Web applications in ASP)


I.

Write an application that contains a list of following technologies:


ASP.NET, ADO.NET, C#.
It also contains a textbox in which the user has to enter a name and a textarea in
which the user has to enter his comments. When the Submit is clicked, the output
should display the name entered in the textbox and the user-selection from the
listbox. All the above should be displayed with the tracing for the page being
enabled.

II.

Write a Web application that generates the IndexOutOfRange exception when a button
is clicked. Instead of displaying the above exception, it redirects the user to a custom
error page. All the above should be done with the trace for the page being enabled.

III.

Create a simple Web Service that converts the temperature from Fahrenheit to Celsius,
and vice versa create a simple Web Service that converts the temperature from
Fahrenheit to Celsius, and vice versa. Also write an ASP program to consume this web
service.

IV.

Write an ASP program to create a proxy.

Experiment 5 (Session Tracking in ASP)


I.

Write a Program in ASP that has a form taking the users name as input. Store this name
in a permanent cookie & whenever the page is opened again, then value of the name field
should be attached with the cookies content.

II.

Use ad-rotator to change advertisements on client side request.

III.

Create a Session dictionary using object tag. In session-on start add keys for Time,
UserAgent, RemoteIP& add appropriate values. Create a simple page to display the
values.

|IV.

Implement Session tracking using user authentication.

V.

Write a Program to delete all cookies of your web site that has created on the clients
computer.

Experiment 6 (Form Validations in PHP)


I.

Write a HTML file to create a simple form with 5 input fieldsviz. Name, Password,
Email, Pincode, Phone No. and a Submit button.

II.

Write a PHP program to demonstrate required field validations to validate that all
input fields are required.

III.

Write a PHP program to validate Name, Email and Password.

IV.

Write a PHP program to display error messages if the above validations do not hold.

V.

Create a form for your college library entering student details for each student in the
college. Validate the form using PHP validators and display error messages.
Experiment 7 (File Handling in PHP)

I.

Create a PHP program to demonstrate opening and closing a file.

II.

Create a PHP program to demonstrate reading a file.

III.

Create a PHP program to demonstrate writing in a file.

IV.

Create a PHP program to read the following text from a file nitkkr.txt National
Institute of Technology, Kurukshetra (or NIT Kurukshetra), is a public engineering
university located in Kurukshetra. In December 2008, it was accredited with the status
of Institute of National Importance (INI)And write to another file learningphp.txt.

V.

Write a program in PHP to print the count of word the as an independent word in a
text file STORY.TXT.For example, if the content of the file STORY.TXT is There
was a monkey in the zoo. The monkey was very naughty. Then the output of the
program should be 2.
Experiment 8 (Databases in PHP)
Assume four users user1, user2, user3 and user4 having the passwords pwd1, pwd2,
pwd3 and pwd4 respectively. Use PHP script for programs 1 and 2.

I.

Create a Cookie and add these four user IDs and passwords to this Cookie.

II.

Read the User id and Passwords entered in the Login form and authenticate with the
values (UserId and Passwords) available in the cookies.If he is a valid user (i.e.,
UserName and Password match) you should welcome him by name (UserName) else
you should display You are not an authenticated user.

III.

Write a PHP which does the following job:


Insert the details of the 3 or 4 users who register with the web site by using
registration form. Authenticate the user when he submits the login form using the
UserName and Password from the database (instead of cookies).

IV.

Create tables in the database which contain the details of items (books in our case like
Book name, Price, Quantity, Amount) of each category. Modify your catalogue page
in such a way that you should connect to the database and extract data from the tables
and display them in the catalogue page using PHP.

V.

Create and delete MYSQL database using PHP.


Experiment 9 (Session Tracking in PHP)

I.

Write a PHP program to start a PHP Session.

II.

Write a PHP program to destroy a PHP Session.

III.

WAP to create a PHP Session without cookies.

IV.

Write a PHP program to store current date-time in a COOKIE and display the Last
visited on date-time on the web page upon reopening of the same page.

V.

Write a PHP program to store page views count in SESSION, to increment the count
on each refresh, and to show the count on web page.
Experiment 10 (Introduction to Python)

I.

Create a new program called hello world.py. You will use this le to write your very
rst Hello, world! program.

II.

Write a program using print that, when run, prints out a tic-tac-toe board.

III.

Using a for loop, write a program that prints out the decimal equivalents of 1/2, 1/3,
1/4... 1/10.

IV.

Write a program using a while loop that asks the user for a number, and prints a
6

countdown from that number to zero. What should your program do if the user inputs
a negative number? As a programmer, you should always consider edge conditions
like these when you program! (Another way to put it- always assume the users of your
program will be trying to nd a way to break it! If you dont include a condition that
catches negative numbers, what will your program do?)
V.

Write a program using a for loop that calculates exponentials. Your program should
ask the user for a base base and an exponent exp, and calculate baseexp.
Experiment 11 (Methods in Python)

I.

Write a method fact that takes a number from the user and prints its factorial.

II.

Write a method rand divis 3 that takes no parameters, generates and prints a random
number, and nally returns True if the randomly generated number is divisible by 3,
and False otherwise. For this method well use a new module, the random module. At
the top of your code, underneath import math, add the line import random.

III.

Write a method roll dice that takes in 2 parameters - the number of sides of the die,
and the number of dice to roll - and generates random roll values for each die rolled.
Print out each roll and then return the string Thats all! An example output:
>>>roll_dice(6, 3)
4
1
6
Thats all!

IV.

Write a function roots that computes the roots of a quadratic equation. Check for
complex roots and print an error message saying that the roots are complex.
Experiment 12 (Graphics using Python)

I.

Drawing Rectangles: To display a rectangle, you need to specify two points: the
upper left corner and the bottom right corner.Remember our y-axis is ipped.
Make a le car.py and try the code below:
from graphics import *
new_win = GraphWin("A Car", 300, 300)
rect = Rectangle( Point( 10,10), Point(200, 100 ) )
rect.setFill( "blue" )
rect.draw( new_win )
7

new_win.mainloop()
Run your program and make sure that the rectangle appears on the screen.
Try changing the color and width of the outline of the rectange. Look at the setOutline
and setWidth methods.
II.

Drawing a Digital Clock: In dig clock.py, create a class called DigitalClock that has
attributes hour, minute, second and pos, and a draw method. The attributes store the
time in military time, i.e. 3:30pm will be hour = 15, minute = 30, second = 23 and the
position - the upper left corner of the rectangle face. Here is the code on how to use it:
from graphics import *
# DigitalClock class definition goes here
new_win = GraphWin("Digital Clock", 300, 300)
clock = DigitalClock(15, 30, 23)
clock.draw(new_win)
new_win.mainloop()
And an example output:
Feel free to choose the appearance of your clock.
Hint: You should add extra methods to help you draw the clock, e.g. a method for
drawing the face, a method for drawing the text, a method returning the time as string.
Choose appropriate names for your methods.

III.

Drawing the car: Create a wheel class. Derive a class for a car from it. Be sure that
wheel.py and car.py are saved in the same directory; this will enable you to use your
denition of Wheel instead of redening it. The car will contain 3 attributes: two
Wheel objects and one Rectangle object (the body of the car) that is horizontal and
whose bottom corners correspond to the centers of the wheels.
References:
1. Swaroop C H, A Byte of Python, ebshelf Inc., 2013.
2. Steven Holzner, PHP: The Complete Reference, McGraw-Hill Osborne,
ISBN-13: 978-0071508544, 2008.
3. ImarSpaanjaars, Beginning ASP.NET 4: in C# and VB, Wrox; 1 edition,
2010.
4. http://www.tutorialspoint.com/
5. http://www.w3schools.com/
6. http://msdn.microsoft.com/en-us/library/ms972337.aspx

Anda mungkin juga menyukai