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

Florian Kinast Flox at gmx.at
Thu Sep 22 13:39:58 EDT 2005


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



More information about the Mono-devel-list mailing list