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 c
As p.campbell pointed-out, the .designer.cs file links the .aspx file to its .aspx.cs CodeBehind file. Without the .designer.cs file, every .aspx page control in the .aspx.cs CodeBehind file will return the error, "does not exist in the current context". The linkage in .designer.cs is done based on the "Inherits" property of the @ Page directive in the aspx file together with the namespace and class of the .aspx.cs CodeBehind file. The final segment of the "Inherits" property must match the class defined in both the CodeBehind file and the .designer.cs file, and the segments prior to it must match the namespace of the .designer.cs and CodeBehind files.
Example: myfile.aspx
<%@ Page Language="C#"
AutoEventWireup="true"
CodeBehind="myfile.aspx.cs"
Inherits="my.namespace.dot.classname" %>
myfile.aspx.cs
namespace my.namespace.dot {
public partial class classname : Page { ... }
}
Note: the CodeBehind file class must inherit from the Page class, or some derivative thereof.
myfile.designer.aspx.cs
namespace my.namespace.dot {
public partial class classname { ... }
}
Note: the .designer.cs class doesn't care about inheritance, just that the class name matches the CodeBehind and .aspx files.
You can regenerate a lost .designer file like this (w3cgeek.com "Regenerate designer.cs"):
Visual Studio should auto-populate the .designer.cs file with all the necessary code to link your .aspx and CodeBehind files. The "does not exist in the current context" errors should now be gone!
EDIT: I added the .designer.cs instructions because the link is dead which was originally posted by p.campbell.