Articles → LIGHT SWITCH 2011 → Confirmation Messagebox In Lightswitch 2011
Confirmation Messagebox In Lightswitch 2011
Software Requirement
- Visual studio 2010 is installed on your machine.
- Visual Studio 2010 service pack 1 is installed on your machine.
- Microsoft Visual Studio Light switch 2011 is installed on your machine.
Prerequisite Knowledge
- How to create screens in lightswitch application?
- How to add buttons in lightswitch application?
- What is button’s execute event?
Showmessagebox Method In Lightswitch
Click to Enlarge
- ShowMessageBox(string message) - In this method we are passing message only, but the caption of the messagebox will be the lightswitch’s screen name in which we are displaying this messagebox. On the message box there will be only one button with caption Ok. Using this method you cannot change the caption of messagebox.
- ShowMessageBox(string message, string caption, MessageBoxOption button) – This method gives you more flexibility in terms of setting the captions and button types. Here the first parameter is for the message which you want to display, second one is to set the caption of messagebox and third one is to set the type of messagebox. The variable button i.e. third parameter is of type MessageBoxOption. On setting the value of this variable we can control which buttons to be displayed in the messagebox.
- Ok – only Ok button will be displayed.
- OkCancel – Ok and Cancel button will be displayed.
- YesNo – Yes and No button will be displayed.
- YesNoCancel – Yes, No and Cancel button will be displayed.
- Yes
- No
- Ok
- Cancel
- None
Click to Enlarge
Confirmation Message Box
- Create a new lightswitch project.
- Add new screen in the project.
- Add a button inside the screen.
- In the button’s execute event write following code
this.ShowMessageBox("Are you sure that you want to delete this item?", "Delete Confirm", MessageBoxOption.YesNoCancel);
Output
Click to Enlarge