Hai provato a mettere language="c#"
al posto di quel al quanto strano per me language="cs" ?
anche se a me funziona pure così.
E poi vorrari dire così :
CSharpCodeBehind.cs :
codice:
namespace myCsCodeBehind
{
using System;
using System.Web.UI.WebControls;
public class cSharpCb : System.Web.UI.Page
{
public System.Web.UI.WebControls.ListBox lstFlowers;
public System.Web.UI.WebControls.Label lblMessage;
public System.Web.UI.WebControls.Button btnSubmit;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lblMessage.Text = "No Selection Yet";
lstFlowers.Items.Add(new ListItem("Tulip"));
lstFlowers.Items.Add(new ListItem("Redbud"));
lstFlowers.Items.Add(new ListItem("Poppy"));
}
}
protected void showSelection(object obj, EventArgs e)
{
lblMessage.Text = "You have selected " + lstFlowers.SelectedItem.Text;
}
}
}
test.aspx :
codice:
<%@ page language="c#" Debug="true" codebehind="CSharpCodeBehind.cs"
inherits="myCsCodeBehind.cSharpCb" %>
<html>
<head>
</head>
<body>
<form runat="server">
Select a flower, and click the submit button please:
<asp:ListBox id="lstFlowers" runat="server" rows="3"></asp:ListBox>
<asp:Button id="btnSubmit" runat="server" text="Submit" onclick="showSelection" />
<asp:Label id=lblMessage runat="server" />
</form>
</body>
</html>
Compila il file CSharpCodeBehind.cs così :
codice:
csc /t:library CSharpCodeBehind.cs
sposta la dll nella cartella "bin"
e poi prova ad aprire nel browser la pagina di test
vedrai che funziona come si deve 