您的位置:首页 > Web前端 > JavaScript

Windows Mobile 5.0 (3) -- 在Mobile Web Form中使用javascript

2007-05-11 23:34 621 查看
补充在(2)中的内容:
Mobile Web Form与Web Form的区别:
Mobile Web Form不支持Theme,但Mobile Web Form可以使用StyleSheet。

修改(1)的内容:

当模拟器和Microsoft ActiveSync无法同步时,可以按照下列步骤就可以立即恢复同步。
1.在Tools->Device Emulator Manager中,选择正在同步的设备右键,选择"Uncradle"。
2.打开Microsoft ActiveSync,按connect,这时候会出现同步画面。
3.在Tools->Device Emulator Manager中,选择"Cradle"继续同步。

Mobile页面上调用所有Asp.net的控件必须订制。

在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中,只有当command2点击时,才执行script。

在ContentTemplate中就能添加asp.net控件,更能添加atlas等。
关于script的属性可以看MSDN的SCRIPT Element | script Object
里面对script的每个属性,使用方法都有实例。
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息