Many LightSwitch developers are novices when it comes to writing code. This sample provides code snippets for a number of common LightSwitch coding tasks. For a detailed explanation of where and how to use the code, see How to: Modify an HTML Screen by Using Code.
Use the Q & A link to provide suggestions for additional code samples that you woul like to see.
When you design HTML screens for a LightSwitch application, you primarily use
designers and tool windows, but you can also use code to modify those screens in
specific ways. By using LightSwitch JavaScript APIs, you can perform the
following data-related tasks:
Set a default value on a data entry screen
Format a number
Validate data on a screen
Delete an item from a screen or a popup
Create a custom modal picker by using a popup
Show a message box, and respond to a user selection
Set the screen title dynamically
Change the title of an application
Enable or disable a button
Customize the Save command to save to multiple data sources
Use a JQuery Mobile Control
Customize a FlipSwitch Control
Get the location of a device
Display a location on a map
Show a numeric keyboard on a device
Adjust the UI for different form factors
Render HTML data directly on a screen
Display a Title on a Popup
We know that writing JavaScript code can be hard when you don’t know the shapes of all the objects you are working with. IntelliSense is one mechanism that can be used to help guide developers to discover and use new APIs.
Whether navigating the contents of the LightSwitch library object (msls) or understanding the properties on generated entity or screen objects, IntelliSense now offers completion lists with appropriate glyphs and tooltip descriptions for each item. Here are some examples: