JavaScript for LightSwitch HTML Client Screens

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 l

 
 
 
 
 
(1)
1,102 times
Add to favorites
4/4/2013
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Unhandled exception using "Get the location of a device"
    2 Posts | Last post July 01, 2013
    • Hi
      I added this code cloned from your sample:
      /// <reference path="../GeneratedArtifacts/viewModel.js" />
      myapp.Survey.created = function (entity) {
          entity.SurveyDateCreated = new Date();
          entity.Status = 'Started';
      
          // Get the location of a device
          if (navigator.geolocation) {
              navigator.geolocation.getCurrentPosition(function (pos) {
                  screen.MyLocation.latitude = pos.coords.latitude.toString();
                  screen.MyLocation.longitude = pos.coords.longitude.toString();
              });
          }
          else {
              alert("Geolocation not supported");
          }
      };
      
      But on running the app I get this error message:
      
      Unhandled exception at line 9, column 13 in http://localhost:62622/Auditor/UserCode/AddEditSurvey.js
      
      0x800a138f - JavaScript runtime error: Unable to set property 'latitude' of undefined or null reference
      
      Please assist.
      Thanks, Mark.
    • Silly mistake. Modified these 2 lines:
                  entity.Latitude = pos.coords.latitude.toString();
                  entity.longitude = pos.coords.longitude.toString();
      Thanks, Mark.
  • HTML5 client How to do multiple file upload
    1 Posts | Last post May 16, 2013
    • Example of how to implement the multiple file upload without SilverLight or even a single file upload
  • How to Rich Text in HTML5 Client
    1 Posts | Last post May 16, 2013
    • An example of how to add a rich Text Editor would be great.
  • When will there be documentation to backup this code sample?
    2 Posts | Last post April 05, 2013
    • I have no experience in JavaScript and would like to start picking this up ASAP, however the article which this document refers to has no content. When will this be available?
    • The updated documentation will be published on Tuesday, 4/9. Sorry for the delay, but we wanted to get the sample out ASAP.