To Lecture Notes

IT 230 -- 4/27/09

 

Review Questions

  1. Where should text files be placed that will be accessed (read or write) using C#?
    Ans: In http://ectweb2.cs.depaul.edu/ssmith/Database
     
  2. Explain how the StreamReader and StreamWriter objects are used.
    Ans: Create a StreamReader or StreamWriter object using the full path name to the file in the constructor call. Then read lines with a StreamReader using the ReadLine method; write lines with a StreamWriter object using the WriteLine or Write methods.
     
  3. Which absolute path name should be used to write to files in the Database folder?
    Ans: e:/ectserver/ssmith/Database/file.txt
     
  4. How can you configure a StreamWriter object to append output to the end of an existing file? Ans: Create the StreamWriter object like this:
    StreamWriter sw = new StreamWriter(path, true);
    where true means append.
     
  5. Write C# code using Visual Studio to read the first 3 lines from the text file C:/it230-ssmith/input.txt and place them in the textboxes txtLine1, txtLine2 and txtLine3.
    public void btnSubmit_Click(object source, EventArgs e)
    {
        StreamReader sr = new StreamReader(C:/it230-ssmith/input.txt);
        txtLine1.Text = sr.ReadLine( );
        txtLine2.Text = sr.ReadLine( );
        txtLine3.Text = sr.ReadLine( );
    }
    

  6. How do you submit an HTML form to an aspx page to be processed by the server?
    Ans: Put all controls to be submitted in a form with action set to the URL where the page is to be posted and method = get or post. Also include an input tag with class=submit.
     
  7. How does the aspx page in the previous example obtain the values of the HTML controls?
    Ans: Using Response.Params[controlName].
     
  8. Write an HTML page with three HTML textboxes and an HTML submit button. These controls should be on a form that is submitted to the page compute-sum.aspx using method=get. This aspx page should compute the sum of the values in the first two boxes and put that sum in the third textbox.

  9. What are the four classs of validation controls we discussed last time?
    ANs: RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator.

 

The Import Tag

 

Posting to a Different ASP.Net Page

 

Arrays in C#

 

The Session and Application Collections

 

Project 4