打算将项目移植到mono上,说做就做,就来了一个测试.

先写了一个aspx网页.加入了datalist控件.代码如下
<%@ Page language="c#"  Inherits="TestASPNET.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    <HEAD>
        <title>WebForm2</title>
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <asp:DataList id="dglist" runat="server">
                <ItemTemplate>
                    <asp:Label id="Label7" runat="server">标识</asp:Label>
                    <asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval (Container.DataItem,"title") %>'>
                    </asp:Label><FONT face="宋体"><BR>
                    </FONT>
                    <asp:Label id="Label8" runat="server">内容</asp:Label>
                    <asp:Label id="Label4" runat="server">创建时间</asp:Label>
                    <asp:Label id="Label5" runat="server" Text='<%# DataBinder.Eval (Container.DataItem,"createdate") %>' >
                    </asp:Label><BR>
                    <asp:Label id=Label2 runat="server" Text='<%# DataBinder.Eval (Container.DataItem,"Text") %>'>
                    </asp:Label><BR>
                    <BR>
                </ItemTemplate>
            </asp:DataList>
        </form>
    </body>
</HTML>

最重要的是加入以下这句:
<%@ Page language="c#"  Inherits="TestASPNET.WebForm2" %>

接下来写codebind代码:WebForm2.cs

using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TestASPNET
{
    public class WebForm2 : System.Web.UI.Page
    {
        protected System.Web.UI.WebControls.DataList dglist ;
   
        private void Page_Load(object sender, System.EventArgs e)
        {
         

            if (this.IsPostBack==false)
            {
                this.BindingData();
            }
        }


        private void BindingData()
        {
       
            System.Data.DataSet  myds =new DataSet();
            string path=Server.MapPath("./file.xml");
            myds.ReadXml(path);
            dglist.DataSource=myds.Tables["file"];
            this.DataBind();
   
        }

        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }
       
     
        private void InitializeComponent()
        {   
            this.Load += new System.EventHandler(this.Page_Load);

        }

    }
}

接下来就是编译WebForm2.cs 并创建Bin目录.
命令如下:
mcs /t:library /out:TestASPNET.dll -r:System.Web -r:System.Data  WebForm2.aspx.cs 

接下来将TestASPNET.dll拷贝到web 目录Bin下面.

启动xsp

http://localhost:8088/WebForm2.aspx
就可以看到结果了.