Reputation: 7484
How would I create or is there built in functionality in XAF to display a message box in a XAF web application?
Upvotes: 1
Views: 9342
Reputation: 4198
The new XAF 17 has Toast Notification:
Application.ShowViewStrategy.ShowMessage(options);
In previous versions you can use JavaScript alert:
WebWindow.CurrentRequestWindow.RegisterClientScript("XafMessageBox", "alert('" + message + "');");
If you need to display a dialog with "OK"/"Cancel" or "Yes"/"No", use this object:
[NonPersistent]
public class ConfirmationPopup
{
public ConfirmationPopup(string prompt)
{
Prompt = prompt;
}
public string Prompt { get; private set; }
}
And this code in View controller:
private void ShowConfirmationPopup(string prompt)
{
var confirmationView = Application.CreateDetailView(Application.CreateObjectSpace(), new ConfirmationPopup(prompt), View);
Application.ShowViewStrategy.ShowViewInPopupWindow(confirmationView, PopupConfirmed, PopupCancelled, okCaption, cancelCaption);
}
private void PopupCancelled()
{
}
private void PopupConfirmed()
{
}
Upvotes: 0
Reputation: 11326
There are two approaches.
You can use the ConfirmationMessage property of any action.
For more advanced scenarios, there is a sample project attached to this support centre ticket which demonstrates how to display a dialog via a PopupWindowShowAction
.
Upvotes: 2