When you start off by telling those who disagree with you that they are not merely in error but in sin, how much of a dialogue do you expect? --Thomas Sowell
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
Share/Print this page:

Subscribe for news, updates and more:

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 22, 2012.
Viewed 10,401 times (5 times today).
Article TypesArticle TypesMicrosoft StackTechnologies
BriefOverviewVisual StudioASP.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

User Comments (1)

Posted 2009 Apr 18 01:21 AM. reply
Designer partial class exists for ASP.NET applications during Development time, just choose the type of the project as "ASP.NET application" instead of "ASP.NET website".

I'm using VS 2008 if this makes any difference.

Mahmoud Basiony
Post Your Comment
  You may post without logging in or login here.
Display Name: Required.
Email: Required. Will not be shown. Used for identicon.
Comment:
Allowed tags: <quote></quote>, <code></code>, <b></b>, <i></i>, <u></u>, <red></red>
 
   Please type text as shown in the image at left.