Experience asp.net on mono

Source: Internet
Author: User
I plan to port the project to mono, and I will do the test.

Write An aspx webpage first. Add the datalist control. The Code is as follows:
<% @ 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"> identifier </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"> content </asp: Label>

<Asp: Label id = "Label4"
Runat = "server"> creation time </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>

The most important thing is to add the following sentence:
<% @ Page language = "c #" Inherits = "TestASPNET. WebForm2" %>

Next, write the codebind code: 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 );

}

}
}

Next, compile WebForm2.cs and create the Bin directory.
The command is as follows:

mcs /t:library /out:TestASPNET.dll -r:System.Web -r:System.Data  WebForm2.aspx.cs 

Next, copy TestASPNET. dll to the web directory Bin.

Start xsp

Http: /localhost: 8088/WebForm2.aspx

The result is displayed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.