Microsoft KB Archive/314519

= HOW TO: Set a Right Softkey on a WML Mobile Device =

Article ID: 314519

Article Last Modified on 12/2/2002

-

APPLIES TO


 * Microsoft Mobile Internet Toolkit 1.0

-



This article was previously published under Q314519



IN THIS TASK
SUMMARY
 * Description of the Technique
 * Steps to Create a Device Filter
 * Steps to Create a ScriptTemplate Template



SUMMARY
This step-by-step article describes how to create a right softkey for Wireless Markup Language (WML) mobile devices.

back to the top

Description of the Technique
Softkeys are buttons on mobile devices that allow users to execute functionality in a mobile Web Form. These buttons are typically located under the screen of the mobile device. The buttons correspond to a value that appears above the button on the screen. This value identifies the action that is taken when the user presses the softkey.

Not all mobile devices have softkeys. Some mobile devices have one softkey, and some mobile devices have two softkeys. When a device has two buttons, the button on the right is called the right softkey.

Microsoft Mobile Internet Toolkit (MMIT) provides a SoftkeyLabel property on some of the mobile controls. In most cases, this property sets the value of the left softkey. Mobile controls do not include a property to set the value of the right softkey.

Because mobile controls do not include a property to set the value of the right softkey, you can use the ScriptTemplate template to insert the WML code that creates the softkey. When you use ScriptTemplate, you must make sure that the code in ScriptTemplate is only rendered to mobile devices that support two softkeys. To do this, you can use the  section of the Web.config file to render the code only to supporting devices.

back to the top

Steps to Create a Device Filter
The  section is available in the Web.config file of your mobile Web application. The device filter uses the MobileCapabilities class to determine whether a device can support a particular feature.

To filter by device in the  section, follow these steps:  Open the Web.config file that is located the root of your mobile Web application.  Add the following code to the  section of your Web.config file:     Save and close the Web.config file.</li></ol>

back to the top

Steps to Create a ScriptTemplate Template
A ScriptTemplate template is part of the mobile DeviceSpecific control. Any code that you include in the ScriptTemplate is rendered immediately after the opening WML tag.

The mobile DeviceSpecific control includes a <Choice> tag. The <Choice> tag contains a filter attribute that uses the device filter that you created in the Web.config file. This filter is important because the code that is included in the ScriptTemplate template does not adaptively render to the browsing device. Therefore, you must limit the ScriptTemplate contents to only those devices that support the exact syntax that included in the template. <ol> Open a mobile Web form.</li>  Add the following code between the mobile form control tags (for example, between the <mobile:form runat=&quot;server&quot; > tag and the </mobile:form> tag): <mobile:DeviceSpecific id=&quot;DeviceSpecific1&quot; runat=&quot;server&quot;> <Choice Filter=&quot;supports2SoftKeys&quot; > <ScriptTemplate> <do type=&quot;options&quot; label=&quot;MS&quot;> <go href=&quot;www.microsoft.com&quot; /> </do> </ScriptTemplate> </Choice> </mobile:DeviceSpecific> </li> Compile and run your application. Notice that the right softkey is available on devices that support the right softkey.</li></ol>

back to the top

Additional query words: soft key

Keywords: kbhowto kbhowtomaster kbwmldevice kbtemplate kbservercontrols KB314519

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.