LetsBlogAbout.NET

Blogging about all that is .NET

Microsoft released ASP.NET MVC 3 earlier this morning at the CodeMash conference. ASP.NET MVC 3 is a framework for developing highly testable and maintainable Web applications by leveraging the Model-View-Controller (MVC) pattern. The framework encourages developers to maintain a clear separation of concerns among the responsibilities of the application – the UI logic using the view, user-input handling using the controller, and the domain logic using the model. ASP.NET MVC applications are easily testable using techniques such as test-driven development (TDD).

The installation package includes templates and tools for Visual Studio 2010 to increase productivity when writing ASP.NET MVC applications. For example, the Add View dialog box takes advantage of customizable code generation (T4) templates to generate a view based on a model object. The default project template allows the developer to automatically hook up a unit-test project that is associated with the ASP.NET MVC application.

Because the ASP.NET MVC framework is built on ASP.NET 4, developers can take advantage of existing ASP.NET features like authentication and authorization, profile settings, localization, and so on.

A ASP.NET MVC 3 Application Upgrader has also been released on Codeplex. This standalone application upgrades ASP.NET MVC 2 applications to ASP.NET MVC 3. It works for both ASP.NET MVC 3 RC 2 and RTM. The tool only supports Visual Studio 2010 solutions and MVC 2 projects targeting .NET 4.

It will not work with VS 2008 solutions, MVC 1 projects, or projects targeting .NET 3.5. Those projects will first have to be upgraded using Visual Studio 2010 and/or retargeted for .NET 4.

The tool will:

  • Create a backup of your entire solution
  • Update all Web Applications and Test projects to reference System.Web.Mvc v3.0
  • Add references to System.Web.Helpers.dll and System.Web.WebPages.dll (new libraries required by MVC 3)
  • Upgrade web.config files to reference System.Web.Mvc v3.0 and add configuration and settings to support the new Razor view engine
  • Add or upgrade JavaScript files that ship with ASP.NET MVC 3 (jQuery 1.4.4, jQuery UI 1.8.7 jQuery Validation 1.7, Microsoft AJAX)
  • Add stylesheets and image assets to support jQuery UI

You can download these releases from the links below:



Well, I get to be one of the lucky people that gets to go to the Microsoft PDC 2008 Conference in Los Angeles, CA on October 27-30. Since 1991, the Professional Developers Conference (PDC) has been Microsoft’s premier gathering of leading-edge developers and architects. Attend the PDC to understand the future of the Microsoft platform and to exchange ideas with fellow professionals. You’ll learn about upcoming products, meet Microsoft’s leaders and top engineers, and write some code.

At this year's conference, Microsoft will be giving a 160GB external USB2 hard drive with all of the bits from the conference to each attendee instead of a collection of DVDs as in the past. It is even rumored that a Beta version of Windows 7 will be included as well.

Channel 9 on MSDN has been producing a series of Countdown to PDC 2008 videos to help everyone get a great overview of what to expect this year at PDC. Here is just a few of the videos that you can watch about the upcoming conference:



kick it on DotNetKicks.com

Earlier this week I received a request from on one of my projects to allow the user to enter only the number (ex. 14) on a web form, but when the number is used in other areas of the project for the number to be shown as fourteen. So, I initially hoped there would be a built in function in C# to allow for this conversion. I wasn't able to find a function to do this out of the box.

A co-worker and I decided to set out to write our own function to accomplish the task. We decided to create the function as a static method in a helper class so that we could call the method from anywhere in the project.

The function is able to convert numbers to word from zero up through the billions. I guess you could always add larger numbers to the function if needed.

Here is the C# code that we came up with:

 
   1: public static string ConvertNumberToWord(long numberVal)
   2: {
   3:    string[] powers = new string[] { "thousand ", "million ", 
   4:       "billion " };
   5:  
   6:    string[] ones = new string[] {"one", "two", "three", "four", 
   7:       "five", "six", "seven", "eight", "nine", "ten",
   8:       "eleven", "twelve", "thirteen", "fourteen", "fifteen",
   9:       "sixteen", "seventeen", "eighteen", "nineteen"};
  10:  
  11:    string[] tens = new string[] {"twenty", "thirty", "forty", 
  12:       "fifty", "sixty", "seventy", "eighty", "ninety"};
  13:  
  14:    string wordValue = "";
  15:  
  16:    if (numberVal == 0) return "zero";
  17:    if (numberVal < 0)
  18:    {
  19:       wordValue = "negative ";
  20:       numberVal = -numberVal;
  21:    }
  22:  
  23:    long[] partStack = new long[] { 0, 0, 0, 0 };
  24:    int partNdx = 0;
  25:  
  26:    while (numberVal > 0)
  27:    {
  28:       partStack[partNdx++] = numberVal % 1000;
  29:       numberVal /= 1000;
  30:    }
  31:  
  32:    for (int i = 3; i >= 0; i--)
  33:    {
  34:       long part = partStack[i];
  35:  
  36:       if (part >= 100)
  37:       {
  38:          wordValue += ones[part / 100 - 1] + " hundred ";
  39:          part %= 100;
  40:       }
  41:  
  42:       if (part >= 20)
  43:       {
  44:          if ((part % 10) != 0) wordValue += tens[part / 10 - 2] + 
  45:             " " + ones[part % 10 - 1] + " ";
  46:          else wordValue += tens[part / 10 - 2] + " ";
  47:       }
  48:       else if (part > 0) wordValue += ones[part - 1] + " ";
  49:  
  50:       if (part != 0 && i > 0) wordValue += powers[i - 1];
  51:    }
  52:  
  53:    return wordValue;
  54: }

Let me know in the comments what you think about the function. If you can find any way to make improvements to the function, please include those in the comments as well.
 


About the author

John Oswalt is a Lead Programmer / Analyst for Tyson Foods, Inc. where he works on the Productivity Management Group which allows him to work with latest Microsoft technologies such as ASP.NET MVC, Silverlight, SharePoint, and many others.

He is the current chairman of the Tyson Developer Conference committee which puts on an internal conference with average attendance of about 200 developers.

John is also the President of the Northwest Arkansas .NET Users' Group which helps evangelize Microsoft .NET technologies and better coding practices.

Sign in