Hi
In my web app->View Controller->ObjectSpace_Committed I need to show a popup modal dialog confirming the record has been saved and some other info. How can I achieve this functionality? Would appreciate some details and if possible a short code example.
Many Thanks
Regards
Yahya
We have closed this ticket because another page addresses its subject:
Platform-Agnostic API for Text NotificationsDisplaying modal pop-up conformation dialog/message box
Answers
Hi Yahya,
Attached is a small sample project that operates fine. Note that we had to add a popup control directly into the Default.aspx markup to avoid the issue I described above.
Here are the full implementation steps:
1. Modify the YourSolutionName.Web/Default.aspx file markup as follows:
ASPx<%@ Page Language="C#" AutoEventWireup="true" Inherits="Default" EnableViewState="false"
ValidateRequest="false" CodeBehind="Default.aspx.cs" %>
<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web" TagPrefix="cc5" %>
...
<form id="form2" runat="server">
...
<cc5:ASPxPopupControl runat="server" ID="PopupControl" ClientInstanceName="Popup" Modal="true" AllowDragging="true" EnableClientSideAPI="true"></cc5:ASPxPopupControl>
...
</form>
2. Include the controller below into the YourSolutionName.Module.Web project:
C#using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Web;
namespace Q365097_1529.Module.Web.Controllers {
public class ShowPopupViewController : ViewController {
private void ObjectSpace_Committed(object sender, EventArgs e) {
WebWindow.CurrentRequestWindow.RegisterStartupScript("showPopupScript", "Popup.Show();");
}
protected override void OnActivated() {
base.OnActivated();
ObjectSpace.Committed += new EventHandler(ObjectSpace_Committed);
}
protected override void OnDeactivated() {
ObjectSpace.Committed -= new EventHandler(ObjectSpace_Committed);
base.OnDeactivated();
}
}
}
Now, a popup window will be shown every time you save your business objects.
Please let us know if this solution meets your business requirements.
Thanks,
Dennis
P.S.
Can I make this ticket public so that other users could access this sample project?
It appears the example is out of date - can't get it to build. Is it possible to update it for the current XAF version?
Thanks in advance,
Dimitris
Hello Yahya,
Thank you for contacting us. I suggest you refer to the Show Result to End Users, After ActionAttribute Is Clicked ticket to learn more on possible solutions. I hope you find this information helpful.
Thanks,
Dennis
---------------
Check if Search Engine is able to answer questions faster than I do!
---------------
Hi
The referenced articles mention ASPxPopupControl but I have no idea how to integrate ASPxPopupControl in XAF in this scenario. Is there an example I can see for clarification? I had already browsed through most of the given articles before posting question. There is just too much information to comprehend and use for the simple option that I need ie displaying a modal popup message from code (not action).
Thanks
Regards
Yahya
Hi,
Have you reviewed the help links given in the Web - Support complex dialogs on the client-side in XAF ASP.NET applications (similar to the MessageBox in Windows Forms) and Support - provide an example, illustrating how to show a dialog window in the Web ( S19008 ) threads?
In addition, I suggest you review the ASPxPopupControl documentation, Code Central examples, and demos: http://demos.devexpress.com/ASPxperienceDemos/PopupControl/ClientSide.aspx
They provide the code examples you are looking for. Let me know if I can assist you further.
Thanks,
Dennis
Hi Dennis
I have checked all of them but which particular one(s) are you recommending for my case? I have asked a specific question and would love a specific answer to my needs instead of a lot of articles which discuss all sorts of things including possible future enhancements to XAF.
Regards
Yahya
Hello Yahya,
In my opinion all these help links are important. Let's start with the How to create ASPxPopupControl at runtime example for the beginning. Let me know if you experience any difficulties with this.
Thanks,
Dennis
Hi Dennis
My question is not how to use web controls in a normal web app. I do it all the time. My question is how to show a dialog specifically in an XAF web app which I am not sure as a starter as to how similar it is to a normal web app. I gather from your reply that using the ASPxPopupControl is the correct strategy in your opinion. In that case my question is can you point me to some specific info on how to integrate ASPxPopupControl in XAF app keeping in mind my specific scenario?
Thanks
Regards
Yahya
>>I gather from your reply that using the ASPxPopupControl is the correct strategy in your opinion.
Yes, you are correct.
>>In that case my question is can you point me to some specific info on how to integrate ASPxPopupControl in XAF app keeping in mind my specific scenario?
The example I suggested shows how to add a popup control to a web page. To get the web page in XAF, create a ViewController and override its OnViewControlsCreated method as follows:
... protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); Page page = Frame.Template as Page; ...
Then you can handle web page events as in regular non-XAF web application.
I hope you find this information helpful.
Thanks,
Dennis
Hi Dennis
Thanks.
My view controller code is given below at the end. Where I am stuck is how to show the dialog at will in the ObjectSpace_Committed event below. Its one thing to show the popup from a normal web page either client side or server side but how to show it from within the view controller code, as in my case, I am not sure. Some help to achieve the show of the popup from code would be appreciated.
Thanks
Regards
Yahya
Public Class TermsandConditionsViewController
Inherits DevExpress.ExpressApp.ViewController
Public page As System.Web.UI.Page
Private Sub TermsandConditionsViewController_Activated(sender As Object, e As System.EventArgs)
AddHandler ObjectSpace.Committed, AddressOf Me.ObjectSpace_Committed
End Sub
Private Sub ObjectSpace_Committed(ByVal sender As Object, ByVal e As EventArgs)
'*** Need to show popup dialog here
End Sub
Private Sub TermsandConditionsViewController_Deactivated(sender As Object, e As System.EventArgs)
RemoveHandler ObjectSpace.Committed, AddressOf Me.ObjectSpace_Committed
End Sub
Protected Overrides Sub OnViewControlsCreated()
MyBase.OnViewControlsCreated()
Dim popup As New ASPxPopupControl()
popup.ID = "popup"
popup.Modal = True
popup.ClientInstanceName = "popup"
popup.HeaderText = "Info Saved"
page.Controls.Add(popup)
End Sub
Private Sub TermsandConditionsViewController_FrameAssigned(sender As Object, e As System.EventArgs) Handles Me.FrameAssigned
page = CType(Frame.Template, System.Web.UI.Page)
End Sub
End Class
Hello,
The following controller worked fine in my tests:
using System; using System.ComponentModel; using System.Collections.Generic; using System.Diagnostics; using System.Text; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Actions; using DevExpress.Persistent.Base; using DevExpress.Web.ASPxPopupControl; using System.Web.UI; using DevExpress.ExpressApp.Web; namespace MainDemo.Module.Web { public partial class ViewController1 : ViewController<DetailView> { ASPxPopupControl popup; public ViewController1() { InitializeComponent(); RegisterActions(components); TargetObjectType = typeof(MainDemo.Module.BusinessObjects.Contact); } protected override void OnActivated() { base.OnActivated(); ObjectSpace.Committed += new EventHandler(ObjectSpace_Committed); } protected override void OnDeactivated() { ObjectSpace.Committed -= new EventHandler(ObjectSpace_Committed); base.OnDeactivated(); } void ObjectSpace_Committed(object sender, EventArgs e) { popup = new ASPxPopupControl(); popup.ID = popup.ClientInstanceName = popup.HeaderText = "popup"; popup.Modal = true; popup.AllowDragging = true; ((Control)View.Control).Controls.Add(popup); WebWindow.CurrentRequestWindow.RegisterStartupScript("showPopup", "popup.Show();"); } } }
I hope you find this information helpful.
Thanks,
Dennis
See Also:
http://community.devexpress.com/forums/t/103663.aspx
http://community.devexpress.com/forums/t/107346.aspx
Hi Dennis
Many thanks. It works great for Save. However for Save and Close popup does not get a chance to appear. Any way to make the popup appear for Save and Close too, then let the user close the popup before view is closed?
Thanks
Regards
Yahya
Hello Yahya,
Displaying a popup on SaveAndXXX does not work because we are adding it to the current View controls collection. Since the View is closed during the operation, no popup is displayed correspondingly.
You can try to add the popup control to the page controls hierarchy: WebWindow.CurrentRequestPage.Form.Controls.Add(popup);
but I think there should be a better solution. I need some time to look for it. Please bear with me.
Thanks,
Dennis
P.S.
BTW, is displaying popup to notify users of a saving operation the only way of accomplishing this task? What about displaying some status information in the top panel or similar?
Hi Dennis
I need a mechanism that shows a message after save and then user selects OK (or Close) and then the remaining code is executed. Modal popup is preferable as it blocks user from doing anything except to close popup before proceeding.
Thanks
Regards
Yahya