March 11, 2013 06:39 by
Scott
In this article you will see how to create a masked password textbox. A masked control is used to save time and reduce the complaints and errors. They enhance the function of the textbox control, which can validate the input. By default the property masked is set to none. A password textbox is used for authorization of an any application. It is very useful to provide security for any application.
1. Open Your VS LightSwitch and Create a New Table
2. Create a Table called Customer
3. Right Click on Screens à Add screen
4. Select New Data Screen
5. Expand Password à select textbox and custom control
6. Go to password properties à Click change
7. Select password control à OK
8. Click write code->Select CreateNewCustomer_InitializeDataWorkSpace->Write the following code
using System;
using System.Linq;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Framework.Client;
using Microsoft.LightSwitch.Presentation;
using Microsoft.LightSwitch.Presentation.Extensions;
namespace LightSwitchApplication
{
public partial class CreateNewCustomer
{
partial void CreateNewCustomer_InitializeDataWorkspace(List<IDataService> saveChangesTo)
{
// Write your code here.
this.CustomerProperty = new Customer();
this.FindControl("Password").ControlAvailable += pwdAvailable;
}
private void pwdAvailable(object sender, ControlAvailableEventArgs e)
{
((System.Windows.Controls.Control)e.Control).LostFocus += PasswordLostFocus;
}
private void PasswordLostFocus(object sender, System.Windows.RoutedEventArgs e)
{
this.CustomerProperty.Password = ((System.Windows.Controls.PasswordBox)sender).Password;
}
partial void CreateNewCustomer_Saved()
{
// Write your code here.
this.Close(false);
Application.Current.ShowDefaultScreen(this.CustomerProperty);
}
}
}
9. Run Application (Press F5)