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

Pascal Fresnay pascalfresnay at free.fr
Thu Sep 22 18:14:42 EDT 2005


Le jeudi 22 septembre 2005 à 19:39 +0200, Florian Kinast a écrit :
> 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).
Please try this simple test :
WebForm1.aspx :
<%@ Page language="c#" Inherits="WebForm1" %>
<html>
	<head>
		<title>Test</title>
	</head>
	<body>
		<asp:form id="Test" method="post" runat="server">
			<asp:Button id="button1" runat="server" Text="Hello"/>
			<asp:Label id="label1" runat="server"/>
		</asp:form>
	</body>
</html>

WebForm1.cs :
using System;
using System.Web.UI.WebControls;
 
public class WebForm1 : System.Web.UI.Page
{
	protected Button button1;
	protected Label label1;
 
	override protected void OnInit(EventArgs e)
	{
		button1.Click += new System.EventHandler(button1_click);
		base.OnInit(e);
	}
 
	private void button1_click(object sender, EventArgs e)
	{
		label1.Text = "Hello World !";
	}
}

mcs WebForm1.cs -target:library -out:bin/WebForm1.dll -r:System.Web.dll
xsp --port:8081
http://localhost:8081/WebForm1.aspx
Does it works ?




More information about the Mono-devel-list mailing list