Be nice to nerds. Chances are you'll end up working for one. --Bill Gates

Where can I view the partial class with designer code in my ASP.NET project?

The partial class concept in Visual Studio 2005 ASP.NET projects


PROBLEM: In my ASP.NET 2.0 project I want to change some default settings for my designer objects like I used to in ASP.NET 1.1, but I can't find the partial class file that's supposed to have all the designer settings. Dawgonnit!

Sorry, it's a trick question. If you're new to .NET 2.0, then you are discovering partial classes for the first time. Partial classes allow one class definition to span more than one file. For a general overview, visit my introductory article on partial classes.

In Windows Forms, the designer code is generated in a separate partial class so that you don't have to deal with it in the file where you are adding most of your code.

However, in ASP.NET the partial class with the designer code doesn't actually exist. It is generated at runtime. This is nice in the sense that you don't have to deal with all the designer code in your code-behind file (which is also a partial class now). However, it's bad in the sense that you can no longer see your object declarations. For example, if you drop a Label onto a web form, the declaration will not show up in your code-behind file. Intellisense will still have it though. If you can't remember the name of your Label object, you'll have to go back to design view or scroll through intellisense.

So, to answer the question, you can't find your partial class with designer code because it doesn't exist until runtime.

Now isn't that a relief.


Version: 6.0.20200920.1535