Sacramento Software Development

Microsoft Exam 70-562

Posted by John Lockwood on September 30th, 2009

  • Configuring and Deploying Web Applications (10 percent)
  • Consuming and Creating Server Controls (20 percent)
  • Working with Data and Services (17 percent)
  • Troubleshooting and Debugging Web Applications (16 percent)
  • Working with ASP.NET AJAX and Client-Side Scripting (15 percent)
  • Targeting Mobile Devices (5 percent)
  • Programming Web Applications (17 percent)

Posted in Microsoft Exam 70-562 | Add a comment »

Copying, Moving, Deleting, Creating, and Reading Files (With Or Without Deep Love Poetry)

Posted by John Lockwood on September 28th, 2009

 <pre>
using System;
using System.IO;

class FileAndFileInfoExample
{
    static void Main(string[] args)
    {
        // Show some mechanisms for creating, moving, 
  // copying and deleting files
        try
        {
            // Get a couple of filenames
            string file1 = @"C:\FileInfoExample_Sample.txt";
            string file2 = @"C:\FileInfoExample_Sample2.txt";

            // Create a text file.
            TextWriter tw = File.CreateText(file1);

            // Write a moving love poem into it.
            tw.WriteLine("I had a girl.");
            tw.WriteLine("Her name was Sue.");
            tw.WriteLine("Loved her dear,");
            tw.WriteLine("Loved her true.");
            tw.WriteLine("Till one day");
            tw.WriteLine("She broke my heart.");
            tw.WriteLine("Took a shotgun -- ");
            tw.WriteLine("Blew me apart.");
            
            // Sealed with a kiss for Sue
            tw.Close();

            // Copy our beautiful creation
            File.Copy(file1, file2);

            // Delete the original
            File.Delete(file1);

            // Move the new file back using File
            File.Move(file2, file1);

            // Using FileInfo instead this time...
            FileInfo fi = new FileInfo(file1);

            // Copy it again.
            fi.CopyTo(file2);

            // Delete the original again
            fi.Delete();

            // Get file2
            fi = new FileInfo(file2);

            // Move it back to one.
            fi.MoveTo(file1);

            // Show our poem to the world
            string [] lovePoem = File.ReadAllLines(file1);
            foreach (string profoundLine in lovePoem)
            {
                Console.WriteLine(profoundLine);
            }

            // Make sure no jealous poets steal our work
            fi = new FileInfo(file1);
            fi.Delete();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }

        Console.ReadKey();
    }
}

</pre>

Posted in Implementing serialization and input/output functionality in a .NET Framework application | 2 Comments »

Featured .NET Certification Study Question

Posted by John Lockwood on September 26th, 2009

We have a new featured question over on the ASPWorkbench. 

Here it is:

Which of the following are differences between XML Serialization and standard serialization? Check all that apply.

A) XML Serialization allows both public and private data members to be serialized, while standard serialization supports only public data.

B) Only standard serialization uses the [Serializable] attribute to determine if a class is serializable.

C) Using the BinaryFormatter class along with standard serialization allows for more runtime efficiency than XML Serialization.

D) Standard serialization does not support the SOAP protocol.

For the answer, head over to the Workbench while this is still the featured question.  (I know, that’s a bit of a cheesy process, but I just haven’t yet had time to get the archives and the site registration going – coming soon though).

Posted in Implementing serialization and input/output functionality in a .NET Framework application | Add a comment »

A Quick DriveInfo Example

Posted by John Lockwood on September 26th, 2009

Too easy.

   <pre>using System;
using System.IO;

public class DriveInfoExample
{
    public static void Main(string [] args)
    {
        DriveInfo [] dilist = DriveInfo.GetDrives();
        foreach (DriveInfo di in dilist)
        {
            Console.WriteLine(&quot;Drive:  {0}, type: {1}&quot;,
            di.Name, di.DriveType);
        }
        Console.ReadKey();
    }
}</pre>

Posted in Implementing serialization and input/output functionality in a .NET Framework application | Add a comment »

Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application (11 percent)

Posted by John Lockwood on September 24th, 2009

This is one of the study objectives for the Microsoft .NET Certification Exam, 70-536.

  • Format data based on culture information.
    May include but is not limited to: Access culture and region information within a .NET Framework application; Format date and time values based on the culture; Format number values based on the culture; Perform culture-sensitive string comparison; Build a custom culture class based on existing culture and region classes.

  • Enhance the user interface of a .NET Framework application by using the System.Drawing namespace.
    May include but is not limited to: Enhance the user interface of a .NET Framework application by using brushes, pens, colors, and fonts; Enhance the user interface of a .NET Framework application by using graphics, images, bitmaps, and icons; Enhance the user interface of a .NET Framework application by using shapes and sizes.

  • Enhance the text handling capabilities of a .NET Framework application, and search, modify, and control text within a .NET Framework application by using regular expressions.
    May include but is not limited to: StringBuilder class; Regex class; Match class and MatchCollection class; Group class and GroupCollection class; Encode text by using Encoding classes.; Decode text by using Decoding classes.; Capture class and CaptureCollection class

Posted in Implementing globalization, drawing, and text manipulation functionality in a .NET Framework application | 1 Comment »

What’s So Funny About the UpdatePanel Control, Love and Understanding?

Posted by John Lockwood on September 21st, 2009

I recently reported that I had a domain for an ASP.NET site to hack around on with nothing on it yet.  Since then I’ve made some progress and had some fun coding some ASP.NET, so I can now show off a minor feature on a new web site, the Featured ASP.NET Certification Question.

This isn’t exactly Google or even StackOverflow yet, to be sure, but there were nevertheless a fair bit of learning and practice goals along the way to this simple looking page. 

The Site and The Control

First, I ported the master page from this site, so that was worth remembering how to do.  Master pages can also expose properties to their content pages, which I haven’t done yet, but perhaps I’ll get into that when I add authentication to the site. 

The next steps were to set up a brain-dead and stubbed out custom control, ExamQuestionControl, while on the lower decks working out the database structure and connection strings for development and production and testing along the way using NUnit tests (Yes, Dan, NUnit Tests).  Once those were in place I began testing out the Plain Old CLR Objects and a simple, one method repository consisting of “QuestionFindByID”, which was all I needed at this point.  I implemented the repository using very basic (and hence certification-friendly) calls into the ADO.NET Connected Classes (one of which forms the basis for my first Featured Question).  Once NUnit had lifted the database up by its bootstraps, It was quite a simple matter to un-stub the formerly brain-dead ExamQuestionControl. 

Once the control was more or less working, I decided (as if setting myself up to take a look at the AJAX chapter) that I didn’t like the fact that the “Show Answer” button posted back the entire page to the server.  Microsoft’s UpdatePanel control provided an elegantly simple way to AJAX enable my control to avoid a full page refresh.  No seriously.  If your hatred of Microsoft is interfering with your Buddhist practice, sit still and contemplate the UpdatePanel control, and you’ll be filled with loving kindness.

Early Hiccups

In the earliest stages of the work, getting the hosting set up and so forth, I ran into a few noteworthy hurdles.  One was that I needed to compile the site and bin deploy the code-behind pages.  Other problems involved deploying an MVC site to godaddy.com, but as you can see from the link, a kind fellow traveler provided the solution.  Before I found that link, I had to re-code the master pages to inherit from System.Web.UI.MasterPage instead of System.Web.Mvc.ViewMasterPage.  Once I found that link, however, I was able to restore the ViewMasterPage with no problems.

What I would recommend to your attention when you get to the deployment phase of your project is to right click on your project and check out the “Publish…” menu option.  As others pointed out in the earlier link, the easiest thing to do turned out to be to publish to a local directory and upload files.  The link above shows you how to bin deploy MVC, and that trick no doubt works on other weird dependency issues.

Once I’d played with that a bit I decided to clean up what I’d originally uploaded, and noticed then that Visual Studio’s publish doesn’t copy over image files referenced in your CSS if you select the option to only copy what’s needed.  Copy those, end of problem.

image

Posted in ASP.NET, ASP.NET MVC | Add a comment »