How to make a Password using Textbox in Microsoft Lightswitch?

A password-masked text box is normally not a problem but when I tried to used it in Microsoft Ligthswitch it was a horrific experience.  Anyways I got it figured out and here are the steps:

1. Add a Data Item in the Screen and name it Password

2. Drag it to the screen, see the sample screen below:

3. The default control of the Password data type is a Textbox you must change it to a Custom Control -> PasswordBox (Windows Control)

4. Now that the Password control has been painted into your screen, its time to make it functioning by using the following code below:

Private Sub pwdAvailable(sender As Object, e As ControlAvailableEventArgs)
AddHandler CType(e.Control, System.Windows.Controls.Control).LostFocus, AddressOf PasswordLostFocus
End Sub

Private Sub PasswordLostFocus(sender As Object, e As System.Windows.RoutedEventArgs)
Me.Password = CType(sender, System.Windows.Controls.PasswordBox).Password
End Sub

5.  Then add code below in your screen initialize data workspace.

AddHandler Me.FindControl("Password").ControlAvailable, AddressOf pwdAvailable

That’s it, below is the sample screen where I use the password-masked textbox.  This is the login screen on my application.

Advertisements
About

Software developer living in the Philippines.

Posted in Lightswitch
One comment on “How to make a Password using Textbox in Microsoft Lightswitch?
  1. […] add the combobox itself.  (It is a custom control from coming from System.Windows.Controls, see my Password Masked blog. for […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Author

Harold Glenn P. Minerva
Software Developer / Tech Enthusiast
Living in the Philippines

View Harold Glenn Minerva's profile on LinkedIn

Instagram

Software Engineer - Seasonal and Range Trading Software. Magenta Trader is a powerful stock market visualization software that increases your probability of trading success.

Software Architect and Founder - Easyfis.com is a multi-tenant cloud-based Software-as-a-Service (SaaS) business app that caters to micro, small and medium trading businesses.

CTO and Co-Founder - We give your company the leverage by providing innovative software solutions products such as Point-of-Sales (POS), Financial Information System (FMIS), Payroll and DTR (HRIS), and many more.

%d bloggers like this: