Creating a MessageBox in LightSwitch 2012

This article describes how to create a MessageBox in a LightSwitch Application (Visual C#) in Visual Studio 2012.

The following is the procedure for creating a MessageBox in LightSwitch 2012.

Step 1

Open the Solution Explorer.

SolutionEx.jpg

Step 2


In the Solution Explorer, right-click on the Screens and choose "Add Screen".

add src1.jpg

Step 3

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

src.jpg

Step 4

The Screen Designer appears.

appli designer.jpg

Step 5

Click on "Add", a drop down list will appear and select the "New" button.

Add button.jpg

The Add Button dialog box appears on the screen.

add button1.jpg

Now the screen designer contains a button.

app desi with msg box.jpg

Step 6

Right-click on that button and and select the "_Execute" method.

Edit execute code.jpg

The code designer appears.

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 CreateNew

    {

        partial void MessageBox_Execute()

        {

            this.ShowMessageBox("Are you sure you want to delete this item?","Delete Confirm", MessageBoxOption.OkCancel);

 

        }

    }

}

Step 7

Press F5 to run the application.

output1.jpg

Click on that button; the dialog box appears on the screen.

okcancel.jpg

Up Next
    Ebook Download
    View all
    Learn
    View all