移动设备的Web应用程序开发----(图像和Utility)

王朝other·作者佚名  2006-01-08
宽屏版  字体: |||超大  

移动.NET图像

移动.NET在不同设备类型上显示不同图像的类型。

Image控件

不同的移动设备显示的兼容性不同。

Image控件允许开发者为不同的设备类型指定图像的不同类型。

Image类型

有些移动设备显示GIF图像,有些显示BMP或者WBM图像,Image控件允许你为每个适合的图像类型指定不同的图像。

这个移动页面显示一个图像:

<%@ Page

Inherits=

"System.Web.UI.MobileControls.MobilePage"%>

<%@ Register

TagPrefix="Mobile"

Namespace="System.Web.UI.MobileControls"

Assembly="System.Web.Mobile" %>

<Mobile:Form runat="server">

<Mobile:Image runat="server">

<DeviceSpecific>

<Choice ImageURL="image.gif" />

<Choice ImageURL="image.bmp" />

<Choice ImageURL="image.wbmp" />

</DeviceSpecific>

</Mobile:Image>

</Mobile:Form>

当这个页面显示在Pocket PC上的时候,将显示成GIF图像。在手机上将根据收集的特性显示成WBMP或者BMP图像。

移动.NET Utility

Utility控件通过很少的代码支持复杂的用户界面。

Adrotator 控件

这个移动页面显示不同的广告:

<%@ Page

Inherits=

"System.Web.UI.MobileControls.MobilePage"%>

<%@ Register

TagPrefix="Mobile"

Namespace="System.Web.UI.MobileControls"

Assembly="System.Web.Mobile" %>

<Mobile:Form runat="server">

<Mobile:AdRotator runat="server"

AdvertisementFile="advertisements.xml">

</Mobile:AdRotator>

</Mobile:Form>

这个是广告(ad)文件叫做“advertisements.xml”:

<?xml version="1.0" ?>

<Advertisements>

<Ad>

<ImageUrl>image1.gif</ImageUrl>

<BmpImageUrl>image1.bmp</BmpImageUrl>

<WBmpImageUrl>image1.wbmp</WBmpImageUrl>

<NavigateUrl>http://www.1.com</NavigateUrl>

<AlternateText>Visit 1</AlternateText>

</Ad>

<Ad>

<ImageUrl>image2.gif</ImageUrl>

<BmpImageUrl>image2.bmp</BmpImageUrl>

<WBmpImageUrl>image2.wbmp</WBmpImageUrl>

<NavigateUrl>http://www.2.com</NavigateUrl>

<AlternateText>Visit 2</AlternateText>

</Ad>

<Ad>

<ImageUrl>image3.gif</ImageUrl>

<BmpImageUrl>image3.bmp</BmpImageUrl>

<WBmpImageUrl>image3.wbmp</WBmpImageUrl>

<NavigateUrl>http://www.3.com</NavigateUrl>

<AlternateText>Visit 3</AlternateText>

</Ad>

</Advertisements>

日历控件

这个也动页面显示一个日历:

<%@ Page

Inherits=

"System.Web.UI.MobileControls.MobilePage"%>

<%@ Register

TagPrefix="Mobile"

Namespace="System.Web.UI.MobileControls"

Assembly="System.Web.Mobile" %>

<script runat="server">

Sub CalChanged(sender as Object,e as EventArgs)

lab1.Text="You selected " & c1.SelectedDate

ActiveForm=f2

End Sub

</script>

<Mobile:Form id="f1" runat="server">

<Mobile:Calendar id="c1"

OnSelectionChanged="CalChanged" runat="server" />

</Mobile:Form>

<Mobile:Form id="f2" runat="server">

<Mobile:Label id="lab1" runat="server" />

</Mobile:Form>

这个例子里日历显示在第一个表单里,当用户从日历里面选择数据时,选择的日期显示在新的页面里。

PhoneCall控件

当用户选择文本这个移动页面显示文本“Tove’s number”和电话号码(555)555-5555。

The PhoneCall Control

<%@ Page

Inherits=

"System.Web.UI.MobileControls.MobilePage"%>

<%@ Register

TagPrefix="Mobile"

Namespace="System.Web.UI.MobileControls"

Assembly="System.Web.Mobile" %>

<Mobile:Form runat="server">

<Mobile:PhoneCall runat="server"

PhoneNumber="(555) 555-5555"

Text="Tove's number"

AlternateFormat="{0}" />

</Mobile:Form>

这里的属性”AllternateFormat”是{0}。设置成这种显示将会显示为文本状。

如果你是用值{1}它将显示成”PhoneNumber”。

你也可以实用如下的构作AlternateFormat =”{0}is{1}”.这时候将会显示“Tove's number is (555) 555-5555”。

Utility 控件

Name

Function

AdRotator

Displays advertisements

Calendar

Displays a calendar

PhoneCall

Calls a telephone number

要了解更多的信息参考MSDN。

(译者注:上面是一个入门的ASP.NET的移动页面的简单的纵向描述,非常简单,希望它可以帮助刚刚入门的网友,当然我在最后还是推荐多看看MSDN,那里又很多很详细的信息,到此这篇简单的文章也算完了。谢谢阅读。谢谢批评指正(尤其是英语J),非常感谢。)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有