ShowViewStrategyBase.ShowViewInPopupWindow(View, Action, Action, String, String) Method
Shows the specified View in a popup dialog with OK and Cancel buttons in WinForms and ASP.NET applications.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v19.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
view | View | A View to be shown in a popup. |
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
okDelegate | Action | *null* | A Action delegate to be executed when the OK button is clicked. This parameter is optional. |
cancelDelegate | Action | *null* | A Action delegate to be executed when the Cancel button is clicked. This parameter is optional. |
okButtonCaption | String | *null* | A string specifying the custom caption of the OK button. This parameter is optional. |
cancelButtonCaption | String | *null* | A string specifying the custom caption of the Cancel button. This parameter is optional. |
Remarks
Example
The ShowViewInPopupWindow method displays the dialog containing the specified View and two buttons - OK and Cancel. Both these buttons close the dialog. Additionally, if the okDelegate and cancelDelegate handlers are specified, they are executed when the corresponding button is clicked.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.DC;
// ...
public class MyDialogController : ViewController {
public MyDialogController() {
var action = new SimpleAction(this, "Email", "View");
action.Execute += Action_Execute;
}
private void Action_Execute(object sender, SimpleActionExecuteEventArgs e) {
var objectSpace = Application.CreateObjectSpace(typeof(MyDialog));
var myDialogObject = new MyDialog("Do you want to send an email?");
var dialogView = Application.CreateDetailView(objectSpace, myDialogObject);
Application.ShowViewStrategy.ShowViewInPopupWindow(dialogView,
() => {
Application.ShowViewStrategy.ShowMessage("You've got mail.");
},
() => {
Application.ShowViewStrategy.ShowMessage("Nothing happened.");
}
);
}
}
[DomainComponent]
public class MyDialog {
public MyDialog(string message) {
this.Message = message;
}
public string Message { get; private set; }
}
You can also use a PopupWindowShowAction to show a Views in a popup window. The Add an Action that Displays a Pop-up Window article describes this approach in detail.
Note
ASP.NET applications have certain specifics:
- The ShowViewInPopupWindow method can be used on XafCallbackManager callbacks initiated by the RaiseXafCallback script. It cannot be used on callbacks of controls (e.g., grid sorting).
- It is not possible to pause the current request to wait for user input.
- Main window is not refreshed when the Cancel button is clicked.