views:

41

answers:

2

Hi everyone,

I'm a really beginner so my question may be appear ridiculous.. But, i wonder how the files .aspx.designer.cs works.. It's the first time i work with a solution containing files .aspx.designer.cs for each pages. So i understand it's declaration of controls used in the .aspx for code-behind..

Here is my questions:

Why sometimes solutions doen't have .aspx.designer.cs files? (is the files hidden or doesn't exists?)

I often have problems with this files, they don't Automatically recreate declarations of controls when i add some in the .aspx code, what am i doing wrong?

Thanks to help poor noob :-)

+1  A: 

The .aspx.designer.xx files are the bridge for the ASP.NET webforms code-behind files and the .aspx markup files. Any server control existing on the ,aspx markup page is represented here. Most important are the name and type of the server control.

This, in part, allows Visual Studio to give the user IntelliSense in the code-behind page for server controls created at design-time.

How they work: Visual Studio will generate, or keep in sync, a protected member in the .designer file when you add/remove a server control from the designer.

  protected global::System.Web.UI.WebControls.DropDownList DropDownList1;

Notice that .designer files create a partial class. This provides the linkage to the code-behind file. That's how Intellisense gets the hook between the .aspx and the code-behind.

p.campbell
Thanks for response but Is it possible to manually ask to rebuild the designer file for a page?
bAN
@ban: you bet, here's how to regenerate your designer file: http://www.undermyhat.org/blog/2009/07/tip-regenerate-aspx-designer-cs-files-when-corrupted/
p.campbell
+1  A: 

Visual Studio has two approaches for creating websites: Web Site Projects and Web Application Projects. (OK, OK, three if you add MVC).

Only Web Application Projects have designer.cs files. Web Site Projects don't have them.

The Web Application Project type was added in Visual Studio 2003.

DOK