To Lecture Notes

IT 230 -- 4/29/09

 

Review Questions

  1. What are the the regular expression symbols for the following?
     

  2. Write regular expressions to validate the following:
     

  3. What is the difference between the Session collection and the Application collection?
    Ans: Values added to the Session collection persists across postbacks, but is restricted to a single browser. The Application collection also persists across postbacks, but can be changed by any browser running the application.
     
  4. Write an application that initializes an int array and a string array, then writes the contents of these arrays to the file c:/Database/output.txt.
    public void Page_Load(object sender, EventArgs e)
    {
        int[ ] a = {3, 5, 7, 9};
        string[ ] b = {one, two, three, four};
        StreamWriter sw = new StreamWriter(c:/Database/output.txt);
        for(int i = 0; i <= 3; i++)
        {
            sr.WriteLine(a[i]);
        }
        for(int i = 0; i <= 3; i++)
        {
            sr.WriteLine(b[i]);
        }
    
    }
    

  5. The file c:/Database/ints.txt contains 10 ints, one in each row. The file c:/Database.strings.txt contains 10 strings, one in each row. Display the ints and strings in a Literal control, one int and string per line.
    public void Page_Load(object sender, EventArgs e)
    {
        litDisplay.Text = ;
        StreamWriter sw1 = new StreamWriter(c:/Database/ints.txt);
        StreamWriter sw2 = new StreamWriter(c:/Database/strings.txt);
        while(sw1.Peek( ) > -1)
        {
            litDisplay.Text += sw1.ReadLine( ) +   + 
                               sw2.ReadLine( ) + <br />;
        }
    }
    
    
  6. Repeat the previous problem, but double space the lines.
    Ans: Change the body of the while loop to this:
            litDisplay.Text += <p> + sw1.ReadLine( ) +   + 
                sw2.ReadLine( ) + </p>;        
    

     
  7. Repeat Problem 7, but put the ints and strings in a table.
    Ans: Change the while loop to this:
        litDisplay.Text += <table>;
        while(sw1.Peek( ) > -1)
        {
            litDisplay.Text += <tr><td> + sw1.ReadLine( ) + </td> + 
                <td> + sw2.ReadLine( ) + </td></tr>;
        }
        litDisplay.text += </table>;
    

  8. Use Visual Studio to create a .css external style page that sets the background color to beige, body and td font to Verdana, body color to navy, and td color to maroon. Be sure to attach the style file to the web page.
    Ans: Use this style page:
    body { background-color:beige; color:navy; font-family: Verdana; }
    td   { color: maroon; font-family: Verdana; }
    

 

Review for Midterm Exam