In my project when I create a webusercontrol or a webform it creates the code behind,
but it also creates a .ascx.designer.cs file.
What is this file for? Can I prevent it from being added when I create a new webform/webusercontrol?
.netasp.netvisual-studio
In my project when I create a webusercontrol or a webform it creates the code behind,
but it also creates a .ascx.designer.cs file.
What is this file for? Can I prevent it from being added when I create a new webform/webusercontrol?
Best Solution
In .NET 1.x, the code that allowed the Visual Studio designer to create a visual representation of the page was included within the code behind file itself. It was usually encapsulated within a region called "Designer generated code". (IIRC!)
New developers often inadvertently made changes to those code sections causing problem when working in design view or compilation errors.
In .NET 2+, with the advent of partial classes, M$ was able to extract that portion of code into a separate partial class that would not interfere with the code written by the developer. This file is usually named as Designer.vb/cs. You should not delete it for the same reasons mentioned above.