移动控件介绍及详细使用方法
2011-01-06 10:58:45 来源:WEB开发网清单5:TextBoxDefault.aspx
< %@ Page Language="C#" AutoEventWireup="true" CodeFile="TextBoxDefault.aspx.cs" Inherits="TextBoxDefault" %>
< %@ 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" >求和
< /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);
}
}
Image控件
为了在移动设备的屏幕上显示一个图片,我们可以在移动WEB窗体上添加一个Image控件,其中Image控件的ImageUrl属性就是用来指定图片所在的位置。还可以设置该控件的NavigateUrl属性,为图像指定一个目标URL。
更多精彩
赞助商链接