0% found this document useful (0 votes)
583 views

Lab Exercises

The document outlines 10 labs with exercises on ASP.NET programming. Lab 1 covers displaying a feedback form and images. Lab 2 focuses on basic web controls like buttons and labels. Lab 3 involves controls like ListBoxes and displaying item information. Labs 4-6 cover validation controls and forms. Labs 7-8 deal with application variables, sessions, tables and SQL queries. Labs 9-10 connect to databases and retrieve data using DataSets and binding controls like CheckBoxLists and RadioButtonLists.

Uploaded by

jay desai
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
583 views

Lab Exercises

The document outlines 10 labs with exercises on ASP.NET programming. Lab 1 covers displaying a feedback form and images. Lab 2 focuses on basic web controls like buttons and labels. Lab 3 involves controls like ListBoxes and displaying item information. Labs 4-6 cover validation controls and forms. Labs 7-8 deal with application variables, sessions, tables and SQL queries. Labs 9-10 connect to databases and retrieve data using DataSets and binding controls like CheckBoxLists and RadioButtonLists.

Uploaded by

jay desai
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Lab Exercises for - ASP.

NET
Lab 1

Excercise 1

Write a program to display the following 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 as seen in the last line of the above
figure must be displayed.

Excercise 2
Write a program to display three images in a line. When any one of the images is clicked, it must be
displayed below. On clicking the displayed image it must be cleared. The screen must look as in the
figure given below:

Lab 2

Excercise 1
Write a simple ASP.NET program to display the following Web Controls:
• A button with text “click me”. The button control must be in the center of the form.
• A label with a text hello
• A checkbox.
The form name must be Web Controls

Excercise 2

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

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

Lab 3

Excercise 1
Write a program containing the following controls:
• A ListBox
• A Button
• An Image
• 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.

Excercise 2

Extend the above program to add the following controls:


• Two labels
• A TextBox
• A Button
One of the labels is displayed adjacent to the textbox , displaying the message “Enter the quantity:”.
When the user enters the quantity in the textbox and clicks the button, the total cost is evaluated and
displayed in another label.

Excercise 3

Write a JavaScript program to display a calendar with the following specifications:


• The width of the border is 10 units
• The border is set to inset style
• The cellpadding is set to 1
• The cellspacing is set to 4
• The height of the calendar is 300px
• The width of the calendar is 500px
• The Days are displayed as “Sun”, “Mon” etc.
• The first day of the week is Saturday
• The days are displayed in brown color
• The names of the next and previous months are displayed as full months
• The next and previous months are displayed in white color
• The days of other months are displayed in gray color
• The SelectionMode is set to DayWeekMonth
• The background color of the selected day(s) is lightblue
• The background color of the selector tab is lightgreen and its text is in black
• The current day is set to blue color and its text is made bold
• The background color of the title is green, its text is white and it is made bold

Excercise 4
Write a JavaScript code that displays two advertisements alternately. When the user clicks on one of
the advertisements, he/she is redirected to “www.amazon.com”, and the other advertisement
redirects the user to “www.fabmart.com”. The weightage of the amazon advertisement is 50 and that
of the other one is 40. The advertisement should be centered horizontally and should cover 60% of the
width of the screen. Its height should be 80 units. The width of the border should be 5
units.

Lab 4

Excercise 1

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

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

Excercise 3
Write a prgoram 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 validates the values entered.

Lab 5

Excercise 1
Create a Form that receives the user name, address, date, nationality, country preferred for working and
skill sets from the user and stores the user name in the client using cookies. The country preferred data
should appear in a dropdownlist whereas, others should be entered in a textbox. Validate all the
controls. The Form is named “formexp.aspx”. The date should appear between “1/1/1900” and
“1/1/2090”.

Lab 6

Excercise 1
Create an application that illustrates how a content can be buffered.
Lab 7

Excercise 1

Create a Global.asax file with Application variables cont, color1 and gotohp. Create a Session variable
called cont1. Initialize cont as 0 and assign any color to color1. For the variable gotohp, give a hyperlink
to any Website. Use the variables in a Web Form. Try these with the lock and unlock methods.

Lab 8

Excercise 1
1. Create table CANDIDATE with the following columns and datatypes

Column name Datatype


Ccode Int
Name Char(20)
DOJ Date

2. Insert few records into the table.


Code 1001 1002 1003
Name S.Raman M.Sushil Mohanyes
DOJ 12-jun-97 12-nov-97 30-jul-97

3. Change the candidate name from ‘S.Raman’ to ‘R.Krishnan’ in the first record in CANDIDATE
table.
4. Drop the table CANDIDATE.
5. Create table Employee with the following columns and datatypes.
Dept Numeric
Name Varchar(20)
Doj Datetime
Sal Float
Desgin Varchar(20)

6. Insert the following rows into the employee table.


10 Shruthi 10-jan-98 4000 Analyst
10 Shanthi 12-jun-98 6000 Manager
20 James 03-jul-99 15000 System manager
20 Goodwill 13-dec-99 10000 Senior analyst

7. Display all the employees whose SAL is less than 3000


8. Display all the employees who are working as MANAGER or ANALYST.
9. Select all the employees who work in department 20 and whose salary exceeds 2000.
10. Select the details of employees whose name starts with ‘J’.
11. Select the employee name, which has ‘o’ as 2 and 3 letter.
12. Update the salary of employees by 1000 for those drawing less than 2000.
13. Find out the average salaries of employees department wise.
14. Create a table “students” with the below given column.
COLUMN DATATYPE
Scode number(6)
Sname char(30)
Marks number(3)

15. Insert few records into the table.


16. Delete those students who get less than 40 marks.

Lab 9

Excercise 1
Write a program to connect to the master database in SQL Server, in the Page_Load event. When the
connection is established, the message “Connection has been established” should be displayed in a label
in the form.

Excercise 2
Write a program to create a table emp in the master database with the following fields:

Field Name Datatype


eno Integer
ename Varchar(20)
salary Float

Suppose the emp table contains the following records:

Eno Ename Salary


98 Shalini 9200
99 Ramesh 7800
100 Rishab 7000
101 Dharani 7800
102 Vijay 8500
103 Yamuna 9500

Excercise 3
Write a program that updates the ename field of the emp table with the given name, where eno=102.

Excercise 4
Write a program to select those rows from the emp table whose eno >=100.
Lab 10

Excercise 1
Select the names of the employees from the emps table. Retrieve the result in a DataSet and display it
in a CheckBoxList.

Excercise 2

Select names from the emps table. Retrieve the result in a DataSet. Bind the DataSet to a
RadioButtonList and display the result in three diferent forms as follows:

i) The RepeatDirection property of the RadioButtonList is set to horizontal and its RepeatLayout
property is set to Table.
ii) The RepeatDirection property of the RadioButtonList is set to Vertical and its RepeatLayout
property is set to Table.
iii) The RepeatLayout property of the RadioButtonList is set to flow.

Excercise 3

Create a Table, which displays two columns and three rows. The first row displays eno, the second
displays ename and the third displays esal, all of these being retrieved from the emps table. Each of the
above is displayed as a drop-down list, containing all the values of the corresponding column in the
table.

Lab 11

Excercise 1

Write a program that binds the properties ID, Name, Price and Qty of a page to the following values:

ID: 10
Name: Wheat
Price: 14.25
Qty: 1000

Excercise 2
Create a RadioButtonList that displays the names of some flowers in two columns. Bind a label to the
RadioButtonList so that when the user selects an option from the list and clicks on a button, the
label displays the flower selected by the user.

Excercise 3
Bind a CheckBoxList to the pname field of the product table in the master database so that all the
name of the product are displayed as a series of checkboxes.
Lab 12

Excercise 1
Write a program to display the records from the database as shown in the figure:

Note: Create a table Customer with records shown in the above figure.

Excercise 2

Write a program to implement the sorting feature in the customer table as shown in the figure:

Note: Create a table Customer with records shown in the above figure.
Excercise 3

Write a program to implement paging feature in the customer table as shown in the figure below.

Note: Create a table Customer with records shown in the above figure.

Lab 13

Excercise 1

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.

Excercise 2

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.

Excercise 3
Write a Web application that retrieves the names of the employees from the emp table. The trace
for the page should be enabled.

Lab 14

Excercise 1
Create a user control that contains a list of colors. Add a button to the Web Form which when
clicked changes the color of the Form to the color selected from the list.

Excercise 2

Create a user control that displays the current date and time. Include it in a Web Form and refresh
it
each time a button is clicked.

Excercise 3
Create a user control that receives the user name and password from the user and validates
them. If the user name is “Radiant” and the password is “asp.net” then the user is authorized,
otherwise not.

Lab 15

Excercise 1
Create a component that receives two numbers from the user through a Web Form, and based
on the user’s selection it adds or subtracts the two numbers and returns the result to the
Web Form. The result should be displayed in the Web Form.

Excerci
se 2
Create two components, the first of which is an abstract class containing an abstract method. The
second component should implement the first component’s abstract class and returns a string
from the method.
Display the result in a Web Form.

Excercise 3

Create a component that contains an array of 100 integers and a corresponding indexer. From
a Web page, assign values to some of its elements. Then the Web Form should display the first
10 elements of the indexer.

Y
Z

You might also like