<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form id="Form1" runat="server">
两数相加
<br /><br />
<mobile:TextBox ID="txtNum1" Runat="server"></mobile:TextBox>
<mobile:TextBox ID="txtNum2" Runat="server"></mobile:TextBox>
<mobile:Label ID="lblResult" Runat="server"></mobile:Label>
<mobile:Command ID="cmdAdd" Runat="server"
OnClick="cmdAdd_Click">
求和
</mobile:Command>
</mobile:Form>
</body>
</html>
清单6:
TextBoxDefault.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class TextBoxDefault :
System.Web.UI.MobileControls.MobilePage
{
protected void cmdAdd_Click(object sender, EventArgs e)
{
int Num1;
int Num2;
Num1 = Convert.ToInt32(txtNum1.Text);
Num2 = Convert.ToInt32(txtNum2.Text);
lblResult.Text = Convert.ToString(Num1 + Num2);
}
}