[Mono-dev] .aspx and .aspx.cs (spliting "codebehind")

Joe Audette joe_audette at yahoo.com
Thu Sep 22 17:19:32 EDT 2005


It works for me on mono, though I develop in VS.NET on
windows and just deploy on mono. For my project
http://www.mojoportal.com which runs on mono I have at
least one developer who compiles on linux with
monodevelop and it works for him too.

You are more than welcome to download the source for
my project to see how I am doing things, maybe it will
help or give you some ideas.

Cheers,

Joe

--- Florian <flox at gmx.at> wrote:

> Hi Joe,
> 
> Thx for ur quick answer, but unfortunately this
> doesn't work neither for
> me.
> 
> I tried it in all possible combinations of
> Codebehind= , src= ,
> Inherits=, AutoEventWireup= (Eventhough I actually
> want
> AutoEventWireup=true, since I wanna use the
> Page_Load function)
> 
> *) Maybe a configuration problem (but it works with
> inline cs code in
> the aspx)
> 
> *) mono-issue? Does anyone have this (aspx and
> apsx.cs seperatly)
> working properly?
> 
> Maybe there are some other advices out there.
> 
> br,
> Flox
> 
> P.S.:
> Basically I thought 
> 1.)Codebehind is more for VS.NET then for mono.
> 2.)src is used in mono (but then when used with
> Inherits the class is
> defined twice which results in error as well)
> 
> ====> I used also the new System.Web.dll posted in
> this list.
> 
> P.S.S:
> I get the following results for the different ways
> to write the header:
> 
> ***1.)
> <%@ Page language="c#" AutoEventWireup="false"
> Codebehind="request.aspx.cs" src="request.aspx.cs"
> %>
> 
> ==> it works, but now reaction if the button is
> clicked
> 
> ***2.)
> <%@ Page language="c#" AutoEventWireup="false"
> Codebehind="request.aspx.cs"src="request.aspx.cs"
> Inherits="workflow.Request %> 
> 
> ==> the namespace of the class Request is workflow
> 
> I do get the following error:
> 
> Compilation Error
> Description: Error compiling a resource required to
> service this
> request. Review your source file and modify it to
> fix this error. 
> 
> Error message:
> /tmp/apache-temp-aspnet-0/43d82bdb/20255.0.cs(26,33)
> :
> error CS0433: The imported type `workflow.Request'
> is defined multiple
> times
> 
> File name: 
> /home/florian/public_html/workflow/request.aspx
> 
> Source File:
> /tmp/apache-temp-aspnet-0/43d82bdb/20255.0.cs
> 
> ***3.)
> <%@ Page language="c#" AutoEventWireup="false"
> Codebehind="request.aspx.cs"
> Inherits="workflow.Request" %>
> 
> ==> the namespace of the class Request is workflow
> 
> I do get the following error:
> 
> Description: Error processing request. 
> 
> Error Message: HTTP 500. 
> 
> Stack Trace: 
> System.Reflection.TargetInvocationException:
> Exception has been thrown by the target of an
> invocation. ---> System.Web.HttpException: Response
> is not available without context
> in <0x00054> System.Web.UI.Page:get_Response ()
> in <0x00015> workflow.Request:.ctor ()
> in <0x0000a> ASP.request_aspx:.ctor ()
> in <0x00000> <unknown method>
> in (wrapper managed-to-native)
> System.Reflection.MonoCMethod:InternalInvoke
> (object,object[])
> in <0x0008d> System.Reflection.MonoCMethod:Invoke
> (System.Object obj, BindingFlags invokeAttr,
> System.Reflection.Binder binder, System.Object[]
> parameters, System.Globalization.CultureInfo
> culture)--- End of inner exception stack trace ---
> 
> in <0x0010e> System.Reflection.MonoCMethod:Invoke
> (System.Object obj, BindingFlags invokeAttr,
> System.Reflection.Binder binder, System.Object[]
> parameters, System.Globalization.CultureInfo
> culture)
> in <0x0001c> System.Reflection.MonoCMethod:Invoke
> (BindingFlags invokeAttr, System.Reflection.Binder
> binder, System.Object[] parameters,
> System.Globalization.CultureInfo culture)
> in <0x00035>
> System.Reflection.ConstructorInfo:Invoke
> (System.Object[] parameters)
> in <0x00116> System.Activator:CreateInstance
> (System.Type type, Boolean nonPublic)
> in <0x0000c> System.Activator:CreateInstance
> (System.Type type)
> in <0x00022>
>
System.Web.UI.TemplateControlParser:GetCompiledInstance
> ()
> in <0x00035>
> System.Web.UI.PageParser:GetCompiledPageInstance
> (System.String virtualPath, System.String inputFile,
> System.Web.HttpContext context)
> in <0x00010>
> System.Web.UI.PageHandlerFactory:GetHandler
> (System.Web.HttpContext context, System.String
> requestType, System.String url, System.String path)
> in <0x001e1> System.Web.HttpApplication:GetHandler
> (System.Web.HttpContext context)
> in <0x00888>
> System.Web.HttpApplication+<Pipeline>__1:MoveNext ()
> 
> 
> On Thu, 2005-09-22 at 11:06 -0700, Joe Audette
> wrote:
> > If you use syntax like this
> > <%@ Page language="c#" AutoEventWireup="false" 
> > Codebehind="request.aspx.cs" Inherits="request" %>
> > 
> > and compile and put the dll in your bin folder it
> > should work
> > 
> > Hope it helps,
> > 
> > Joe
> > 
> > --- Florian Kinast <Flox at gmx.at> wrote:
> > 
> > > Hi Everybody,
> > > 
> > > I am sorry if this problem is not appropriate
> here,
> > > but I am looking for
> > > a solution to that now for some time.
> > > 
> > > Problem:
> > > 
> > > I got a request.aspx which works if I put the
> > > "codebehind" and the aspx
> > > in one file.
> > > If I try to split it into a request.aspx and
> > > request.aspx.cs it doesn't
> > > work anymore: There is just no reaction on the
> click
> > > (it seems to load, but
> > > just the same pages comes back).
> > > 
> > > .) Variant 1 (WORKING)
> > > request.aspx:
> > > <%@ language="C#" %>
> > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
> > > Transitional//EN" >
> > > <html>
> > >         <script runat="server">
> > >                 void btnEnter_Click(object o,
> > > EventArgs e)
> > >                 {
> > >                         btnEnter.Text="Clicked";
> > >                 }
> > > 
> > >         </script>
> > >         <body>
> > >         <form runat="server">
> > >                 <asp:button id="btnEnter"
> > > Text="OnLoad"
> > > onClick="btnEnter_Click"/>
> > >         </form>
> > >         </body>
> > > </html>
> > > 
> > > .) Variant 2 (NOT WORKING)
> > > request.aspx:
> > > <%@ Page language="c#" src="request.aspx.cs" %>
> > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
> > > Transitional//EN" >
> > > <html>
> > >         <body>
> > >         <form id="Form1" method="post"
> > > runat="server">
> > >                 <asp:button id="btnEnter"
> > > Text="OnLoad" runat="server"/>
> > >         </form>
> > >         </body>
> > > </html>
> > > 
> > > request.aspx.cs:
> > > using System;
> > > using System.Web.UI;
> > > using System.Web.UI.WebControls;
> > > 
> > > namespace workflow
> > > {
> > >         public class Request :
> System.Web.UI.Page
> > >         {
> > >                 protected
> > > System.Web.UI.WebControls.Button btnEnter;
> > > 
> > >                 override protected void
> > > OnInit(EventArgs e)
> > >                 {
> > >                         InitializeComponent();
> > >                         base.OnInit(e);
> > >                 }
> > > 
> > >                 private void
> InitializeComponent()
> > >                 {
> > >                         this.btnEnter.Click +=
> new
> > > System.EventHandler(this.btn$
> > >                         this.Load += new
> > > System.EventHandler(this.Page_Load);
> > >                 }
> > > 
> > >                 protected void Page_Load(object
> > > sender, System.EventArgs e)
> > >                 {
> > > 
> > >                }
> > > 
> > >                 protected void
> btnEnter_Click(object
> > > sender,
> > > System.EventArgs e)
> > >                 {
> > >                        this.btnEnter.Text =
> > > "Clicked";
> > >                 }
> > >         }
> > > }
> > > 
> > > I tried it with various options (with/without
> > > InitializeComponent and
> > > other commands also placed directly in the
> Page_Load
> > > function) and it
> > > never worked.
> > > 
> > > MY SETTING:
> > > Gentoo, apache2, mod_mono, mono-1.1.9, kernel
> 2.6.13
> > > 
> > > Could this missing functionality be caused by
> > > wrongly configured
> > > httpd.conf/mod_mono.conf or something like that?
> > > 
> > > I am rather new to the mono and I want to
> migrate a
> > > quite complex
> > > project from VS.NET/Windows to mono/linux. But
> at
> > > the moment I get stuck
> > > at the very basic levels.
> > > 
> > > If this is the wrong platform to ask questions I
> am
> > > sorry and ask you to
> > > tell me where else I could ask this and what
> would
> > > be the appropriate
> > > questions in this list.
> > > 
> > > I am very thankfull for every help.
> > > Thx a lot in advance,
> > > Flox
> > > 
> > > P.S:
> > > I tried it also with creating a .dll an puting
> it in
> > > the same as well as
> > > in the bin/ directory of the Application.
> > > 
> > > Might I need to register the dll somewhere
> (gac)?
> > > 
> > > 
> > > -- 
> > > GMX DSL = Maximale Leistung zum minimalen Preis!
> > > 2000 MB nur 2,99, Flatrate ab 4,99 Euro/Monat:
> > > http://www.gmx.net/de/go/dsl
> > > _______________________________________________
> > > Mono-devel-list mailing list
> > > Mono-devel-list at lists.ximian.com
> > >
> >
>
http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > > 
> > 
> > 
> > joe_audette [at] yahoo dotcom
> > http://www.joeaudette.com
> > http://www.mojoportal.com
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> >
>
http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > 
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
>
http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 


joe_audette [at] yahoo dotcom
http://www.joeaudette.com
http://www.mojoportal.com



More information about the Mono-devel-list mailing list