To Exam Info

Midterm Review Questions

  1. Define these terms:
    Ans: Postback: When the ASP.Net page is redisplayed after it is sent back to the server. Use if (!Page.PostBack) to only execute the Page_Load event handler the first time the page is loaded.
     
  2. Describe the steps required for a browser to request and obtain a web page.
    Ans: See the bottom of the Domain Name System Page.
     
  3. How do avoid writing the fully qualified name System.IO.StreamReader in C# code? Ans: Use an Import tag:
    <%@ Import Namespace=System.IO >
    

     
  4. What do these Windows Command Prompt commands do?
  5. Ans: ipconfig lists the IP address of the current host, netstat lists the IP address and port numbers of all current connections to the current host, ping can be used to obtain the IP address of any internet URL.
     
  6. What does each of these telecommunications equipment items do?
  7. Ans: See the bottom of the OSI Seven Layer Model.
     
  8. How do you modify a Visual Studio ASP.Net project to combine the HTML and C# code-behind files to create an .aspx file suitable for uploading to ectweb2.
    Ans:
    1. Copy all event handlers from the code-behind file into script tags <script runat=server> ... </script> placed between the Page tag and the html tag.
    2. Select and delete all code in the code-behind files (Default.aspx.cs and Default.aspx.designer.cs).
    3. Copy and paste the code in Default.aspx into a Notepad file named projn.aspx, where n is your project number.
    4. Upload projn.aspx to ectweb2. Do not upload any code-behind files to ectweb2.
       
    5. Explain how the Split method of string works. Write a short .aspx file that tests the Split method.
      string line = Alice,F,35;
      string[ ] fields = line.Split(',');
      for(int i = 0; i <= 2; i++)
      {
          Response.Write(fields[i]);
      }
      

       
    6. Use Visual Studio to test the StreamReader class methods ReadLine and Peek.
      Ans: First create an input file text.txt and place it in the folder c:/it130. It should contain the lines
      Test line 1.
      Test line 2.
      Test line 3.
      
      Then run this code
      public void Page_Load(object source, EventArgs e)
      {
          StreamReader sr = new StreamReader(c:/it130/test.txt)
          string line1 = sr.ReadLine( );
          Response.Write(Line1:  + line1 + value of Peek:  +
              sr.Peek( ) + 
      ); string line1 = sr.ReadLine( ); Response.Write(Line2: + line1 + value of Peek: + sr.Peek( ) +
      ); string line1 = sr.ReadLine( ); Response.Write(Line3: + line1 + value of Peek: + sr.Peek( ) +
      ); }
      The output should repeat line1, line2 and line3, give nonnegative return values of Peek for lines 1 and 2, and return -1 for line3.
       
    7. Write .aspx files with textboxes txtIn and txtout and a Submit button that do the following:
       
      1. Displays yes in txtOut if the string in txtIn starts with the letter A or a; no otherwise.
         
      2. Displays yes in txtOut if the string in txtIn ends with the string ing; no otherwise.
         
      3. Display yes in txtOut if the string is entirely uppercase.

    8. Describe each of the ASP.Net Validation controls. Test them with Example 34 (regex.aspx).
       
    9. Write regular expressions to validate each of the following:
       
      1. Five digit zip code. Example: 64538
         
      2. Five digit zip code with optional 4 digit extension. Example: 64538-7346
         
      3. One of the letters F, f, M, or m, for male or female. Example: F
         
      4. Social security number. Example: 436-43-4399
         
      5. Legal C# variable name. Example: entry5
         
      6. Telephone number. Example: (312)728-5487
         
      7. Illinois drivers license number.

    10. A textfile contains one word per line. Write .aspx files that do the following:
       
      1. Display the average lengths of the words in the textfile in txtOut. Assume one word per line in the input file.
         
      2. Display the concatenated third, fifth, and seventh words in the file separated with stars (*) and display the resulting string in txtOut.
         
      3. Read a number in txtIn. Read the line in the textfile corresponding to this number and display it in txtOut. Display NaN if the input is not a number.
         
      4. An input file looks like this:
        Alice,35
        Bob,41
        Casey,23
        Doug,28
        Gail,43
        Stephanie,34
        Zoe,19
        
        Load the date into two arrays, which are then added to the Session collection. Display the date in a Literal when a button with caption Display Data is clicked.