Email Address DataType in LightSwitch 2012

This article describes how to use the Email Address data type in LightSwitch Visual Studio 2012.

The following is the procedure for using Email Address Datatype.

Step 1

Open the LightSwitch Application in Visual Studio 2012 and go to the Solution Explorer.

Solution Explorer

Right-click on the Data Source and choose "Add Table".

Add Table

The table appears in the table designer window. Insert the records in the following table.

student table

Here in the table I have added a record named "Email" and I have taken its datatype as "Email Address" as shown below.

Select Email Address Datatype

Step 2

Now once again go to the Solution Explorer, right-click on Screens and choose "Add Screen".

Add Screen

The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template, inside screen information, choose "Student" under screen data and provide some name to the Screen and click the "OK" button.

Add New Screen

The Screen Designer appears as shown below.

Select Email from Screen Designer

Press F5 to run the application. We get the following output screen.

Output of Editable Grid Screen

Now stop debugging the application. The application designer screen appears. Click on Email under the Data Grid Row, and go to the property window and select the Label Position as Left Aligned.

Select Email from Screen Designer

Properties window for setting Label Position

Step 3

Once again press F5 to run the application, we will get the following output screen.

Output with Email Label Left Aligned

Stop debugging the application.

We can also set the text alignment from the property window.

properties for setting Text

Step 4

Once again go to the Property window of Email in the screen designer and select Control Type. Here I have chosen "Email Address Viewer" from the Control Type drop down list.

properties window control type

As I select the
"Email Address Viewer" from the control type, the "Show As Link" Checkbox appears in the property window just below the Control Type. Mark the checkbox as checked as shown below.

Mark Show As Link in Property Window

Step 5

Once again press F5 to run the application. We will get the following output where the Email appears in the form of a hyperlink.

Email address appear as Link

Click on the Email link. We will get the entire information of that specific person in another Screen as shown.

particular user record will be available


Similar Articles