Home > 2010 Winter BTI420 > BTI420 Lab 4

BTI420 Lab 4

February 5, 2010 Leave a comment Go to comments

Lab 4 helps you learn the topics for working with the web server’s file system. It is due by Friday February 12. .

BTI420 Lab 4 – due Fri Feb 12

Assigned: During Week 4

Due date: Friday, February 12, 2010, at 8:00am

Grade value: 3% of your final course grade

Grading method: The following will be checked:

  • Your “labs/lab4.aspx” page
  • Correct interactive operation of the page’s logic
  • Implementation of the specifications
  • Code writing quality, including commenting



Work with the web server’s file system

Enable “file upload”

Perform file creation and editing operations

Read and process simple text files


Introduction to the problem that you will solve

A web form is needed that will allow a browser user to upload a text file to the web site. It will also allow the user to make a copy of the file with some additional data. Then, it will allow the user to view the contents of the modified file.

In addition, the page will allow the user to search the contents of the modified file, and display all matching lines of text in a multi-line textbox.

Therefore, in summary, the web form will allow these four tasks:

  1. Enable a browser user to upload a text file to the web site
  2. Allow the user to make a copy of the file, with some additional data added to it
  3. Enable the browser user to view the contents of the copied file
  4. Permit the user to search the contents of the copied file, and view the search results

A working example of Lab 4 is here. You DO NOT have to exactly copy the appearance and functionality. Your lab MAY look and work a bit different.



Create lab4.aspx in your labs folder. Use your “labs.master” master page that you created in Lab 3. (You will use “labs.master” in all your labs from Lab 3 through to Lab 7).

On the web form, create four areas. You do NOT have to use the show/hide pattern from Lab 3, but you could still use panels if you wish. You can apply a style to a panel, so that it has, for example, a distinct background colour. If you like this idea, do the following:

  • Show your Lab 4 aspx markup
  • In its head “content” area, add a CSS class for each panel
  • For each CSS class, add rules for the appearance you want
  • When adding and configuring a panel web server control, set its “CssClass” property to the CSS class you want it to use

First area – upload a text file: Create an area that will allow the user to upload a line-oriented text file to your web site. You must create a folder in your web site that will hold files that are created or modified with “file I/O” operations. We suggest: ~/assets/uploads

Obviously, you must use the recommended impersonation technique to make this possible for this lab4.aspx to make changes to the web server’s file system.

While you are testing, you can upload any line-oriented text file. Make sure it is big enough to be interesting; it must be 1,000 bytes/characters or larger, up to a maximum size of 100,000 bytes/characters. On a typical Windows-based computer, the C:\WINDOWS folder has lots of .txt and .log files which meet the criteria.

Hint: Save the web server’s full path and name of the file that was just uploaded. You will need this name in the second area…

Second area – copy and modify the uploaded file: Next, create an area on the page that will enable the user to make a copy of the uploaded file. Store the copy of the file in the same “assets/uploads” folder as the uploaded original.

Insert – at the top/beginning of the new file – your name, and the current warp server date and time. The name of the copied file will be in the format:


Third area – view a file: Then, provide a way for the user to view the contents of the file. You should probably show the user a list control (dropdown list? listbox?), to allow them to select the file they want to view, and then place the file’s contents into a multi-line textbox that shows the contents of the file.

Fourth and last area – search for text in a selected file: Finally, give the user a way to search the contents of a selected text file, and display the search results.

Use a simple search algorithm: Search for the entire search term entered by the user.

For example, if the user enters “hello”, search only for “hello”. If the user enters “hello world”, search only for the complete term “hello world”, and not the individual “hello” or “world” words/terms. (This makes it easier.) Make your search case-insensitive.


Submitting your work

Update your web site home page to add a link to this lab.

When you do a lab exercise, you are creating it online on the warp server. Therefore, you do NOT have to submit paperwork to your professor. Just do the lab, and your professor will find it (as long as it is in the right location!).


Categories: 2010 Winter BTI420
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: