Moving ASP.NET Designer Generated Code to Separate Designer.vb File

Introduction

If you’ve converted an an ASP.NET application from versions of Visual Studio 2003 and earlier to 2005 and beyond, you’ll notice the converted web pages behave slightly differently than those natively generated in new projects. The difference is that designer generated code used to have to live inline with developer code because all class properties needed to exist within the same file.

Solution

Starting in .NET 2.0, the compiler can now use the partial keyword which allows you to split up the declaration of a class over n number of files. The paved the way for Visual Studio to break apart the ugly code it generates from the (hopefully) beautiful code you’ve written. To make use of this feature on old asp.net web applications that have been converted to a compatible version of visual studio, simply do the following two steps.

5 Easy Steps

  1. Take the entire region label Web Form Designer Generated Code and Delete it from your code behind file:

  2. Our Solution Explorer currently looks likes this:

  3. Right Click on the .aspx or .ascx page and Select Convert to Web Application

  4. It will add a designer file with all the code we just deleted:

  5. Of course, if you turn of “Show All Files”, you’ll still only see the page in your solution explorer

And that’s it! Now enjoy the faster design time analysis and cleaner code that comes from separating your generated code and your written code.

5 comments:

  1. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. bespoke interior design

    ReplyDelete
  2. Excellent and very exciting site. Love to watch. Keep Rocking. Zayn Malik net worth

    ReplyDelete
  3. This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. Zayn Malik net worth

    ReplyDelete
  4. The standard clothing of girls and women was for centuries a dress and a skirt with blouse and within these clothing types the designs for special occasions and festive events were created.

    www.reeligion.net/products/womens-spear-fishing-crop-shirt-black

    ReplyDelete