locked
How to do add screen and do validation in VS 2013 Light Switch RRS feed

  • Question

  • Hi All, Iam a very beginner to Light Switch. Can any please help me How to do add screen and do validation in VS 2013 Light Switch.
    Saturday, November 1, 2014 7:50 AM

Answers

  • You can find lots of help on getting started with LightSwitch here.

    http://msdn.microsoft.com/en-us/library/vstudio/ff852064.aspx

    http://blogs.msdn.com/b/bethmassi/archive/2011/12/01/beginning-lightswitch-getting-started.aspx

    http://msdn.microsoft.com/en-us/vstudio/lightswitch.aspxValidation is usually done by adding Validate routines to the entities.

    Click on a field in the entity designer then click the dropdown Write Code button at the top of the screen and select the field's Validate event. Here you write the code that checks the field is valid and if it isn't you add a validation message to the result.

    Private Sub MileageRate_Validate(results As EntityValidationResultsBuilder)
     
        If ExpenseType IsNot Nothing AndAlso ExpenseType.IsMileage AndAlso Not MileageRate.HasValue Then
            results.AddPropertyResult("Mileage Expense Item must have a Mileage Rate", ValidationSeverity.Error, Me.Details.Properties.MileageRate, "MileageRateRequired")
        End If
     
    End Sub

    Validation messages can be information, warnings or errors. Validation errors will stop the user saving the data.

    Remember to code defensively. Don't assume that any field will have a value. Keep validation code as short and quick as possible as it will be called very often as the user moves around the screen as well as when they save the data.


    Simon Jones
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to "Mark as Answer". This will help other people find answers to their problems more quickly.

    • Marked as answer by Angie Xu Monday, November 10, 2014 6:52 AM
    Saturday, November 1, 2014 9:43 AM