This is the steps you need to follow:
1. First of all we created a table in LightSwitch application.
3. Double click one customer and write an email without domain (which shows an error.) likes below image.
4. Change the length of state (no error)->cut->ok.
5. Come back to the customer page like below image.
6. Now go to phone properties->change maximum length(255 replace by 25)-> then go to email properties set default domain (gmail.com) ->then go to postal code properties change maximum length(255 replace by 10)-> then go to state properties change maximum length(255 replace by 2) and click custom validation (.cs page will be open) then write coding.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
public partial class Customer
{
partial void State_Validate(EntityValidationResultsBuilder results)
{
// results.AddPropertyError("<Error-Message>");
if (!string.IsNullOrEmpty(this.State))
{
this.State = this.State.ToUpper();
}
}
}
}
Code Description: This code converts the lowercase letter in to uppercase letter of state name.
7. Add a new property gender->then go to properties of gender ->then click choice list and add value and display name ->ok likes below image.
8. Go to computed property->add name (Full Name)->properties->click edit method then write code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
public partial class Customer
{
partial void FullName_Compute(ref string result)
{
// Set result to the desired field value
result = this.LastName + " " + this.FirstName;
}
}
}
Code Description: This code print the full name of customer.
9. Save->go to customer property->choose summary property->full name looks likes below image.
10. Run the application->open the first customer ->shows full name likes blow image
11. Click design screen and add Full Name like the below image.
12. Go to Last Name properties->uncheck show as a link->Go to Full Name properties->check show as a link->save->open any customer->change status (maximum length will be 2) and postal code (maximum length will be 10)->design screen->yes (likes below image).
13. Add gender in the customer->save likes below image.
14. Now we can choose Male or Female from gender likes below image.
15. Save. Now we can write an email without domain name then there will be no error.
If we write state name which length is more than 2, then there will be an error like in the below image.
If we write postal code which length is more than 10, then there will be an error like below