Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer. --Fred Brooks, Jr.

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

By steve on May 26, 2007.
Updated on January 12, 2013.
Viewed 11,489 times (0 times today).
DeveloperTips and TutorialsASP.NET

Summary

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.

Back to Top
comments powered by Disqus
Welcome to my blog about software development and the Microsoft stack.

I've been a full time .NET developer for ten years, but I didn't start my professional life as a programmer ... more

Subscribe to my email newsletter for news, updates and more!

Sign Up!

Share/Print this page: