Windows Mobile 5.0 (3) -- 在Mobile Web Form中使用javas2008-3-12 14:22:22
补充在(2)中的内容: Mobile Web Form与Web Form的区别: Mobile Web Form不支持Theme,但Mobile Web Form可以使用StyleSheet。 修改(1)的内容: 在Mobile Web Form中使用javascript的方法: 由于有些手机能够支持javascript,所以只有支持javascript的手机才能显示出效果,所以需要定制,在支持的手机中实现javascript效果。 <mobile:Form id="Form1" runat="server" OnLoad="Form1_Load"> <mobile:Label ID="Label1" Runat="server" Font-Bold="True">Student Name:</mobile:Label> <mobile:TextBox ID="txtStName" Runat="server"></mobile:TextBox> <mobile:Command ID="Command1" Runat="server" OnClick="Command1_Click1">Get Info</mobile:Command> <mobile:Command ID="Command2" Runat="server">Client Event</mobile:Command> <mobile:Panel ID="Panel1" Runat="server"> <mobile:DeviceSpecific ID="DSP1" Runat="server"> <Choice Filter="isHTML32" Xmlns="http://schemas.microsoft.com/mobile/html32template"> <ContentTemplate> <asp:CheckBox ID="chkBox" runat="server" Text="CheckBox Control" />![]() <Script language="jscript" for="window" event="onload">![]() window.Form1.Command1.onclick = ShowMsg; function ShowMsg(e)![]() { alert("Msg!"); } </Script>![]() <Script language="jscript" for="Command2" event="onclick">![]() alert("Msg!"); </Script> </ContentTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Panel> </mobile:Form>其中在panel中放置定制<mobile:DeviceSpecific ID="DSP1" Runat="server"> 定制条件是只要支持HTML就行<Choice Filter="isHTML32"> 在ContentTemplate中插入script代码,其中for是针对的控件,Mobile Web Form中用window代替document。Event表示对于指定的控件,出现指定的事件时执行scipt中的操作。 第一个script中,当页面onload的时,执行script,并指定command1的onclick事件。 关于script的属性可以看MSDN的SCRIPT Element | script Object 里面对script的每个属性,使用方法都有实例。 评论
|
||




window.Form1.Command1.onclick 
}