[MonoDevelop] Codebehind and bin control

Michael Hutchinson m.j.hutchinson at gmail.com
Mon Jan 26 19:05:03 EST 2009


On Fri, Jan 16, 2009 at 9:59 PM, piagent <piagent at nyc.rr.com> wrote:
>
> 1) How do a get the IDE to understand Codebehind.  I allows me to edit it in
> to the file and I can select the .cs not to be compiled but it will not
> deploy.
>
> 2) If two .cs files are generated (partials) how do I get both into the
> .aspx in a codebehind?  Is this correct?
> <%@ Page Language="C#" Codebehind="Default.aspx.cs"
> Inherits="aspfirst.Default" %>
> <%@ Page Language="C#" Codebehind="Default.designer.aspx.cs"
> Inherits="aspfirst.Default" %>

This will not work, because you can only have one Page directive per
page. However, the CodeBehind attribute is ignored by .NET, Mono and
MD -- only VS2003 uses it AFAIK. All you need is <%@ Page
Language="C#" Inherits="aspfirst.Default" %>

The important attribute is "Inherits". This specifies the full name of
the class that the page will inherit. The ASP.NET compiler will look
for this class in all the assemblies in bin/. The C# compiler
automatically merges the partial classes.

Note: this is the "web app" compilation model, where the codebehind is
compiled by the IDE. The "web site" model involves using a CodeFile
attribute, and no designer.cs file; the codebehind is compiled by the
server, which creates the designer file is created when the page is
compiled. Although Mono's ASP.NET implementation supports the both
models, MD only supports "web apps". See
http://mjhutchinson.com/journal/2008/08/15/web_application_projects_md_and_vwd
for a little more info.

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Monodevelop-list mailing list