Ticket T472674
Visible to All Users

Questions on the ShowViewInPopupWindow and PopupWindowShowAction usage

created 8 years ago

[DevExpress Support Team: CLONED FROM S19008: Show complex dialogs in XAF ASP.NET applications (similar to the MessageBox in Windows Forms)]
Not Work.

C#
namespace Solution28.Module.Controllers { public partial class ViewController1 : ViewController { public ViewController1() { InitializeComponent(); RegisterActions(components); } private void popupWindowShowAction1_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) { //Do something when the OK button is pressed. } private void popupWindowShowAction1_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) { //e.View = e.Application.CreateDashboardView(e.Application.CreateObjectSpace(), "ConfirmationMessageView", false); Application.ShowViewStrategy.ShowViewInPopupWindow(Application.CreateListView(typeof(DomainObject1), true)); } private void popupWindowShowAction1_Cancel(object sender, EventArgs e) { //Do something when the Cancel button is pressed. } } }

Answers approved by DevExpress Support

created 8 years ago

Hello,

First, you must assign the e.View property in the CustomizePopupWindowParams event handler. Please take another moment to review the following article from our getting started tutorial to learn more about the correct PopupWindowShowAction usage: Extend Functionality > Add an Action that Displays a Pop-up Window

Second, calling the ShowViewInPopupWindow method from this place looks very strange, because technically, several popup windows are being shown in an unexpected order. As a result, the following exception should occur in v16.2.3, as expected:

Code
The error occurred:   Type: ArgumentException Message: An item with the same key has already been added. Data: 0 entries Stack trace:   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at DevExpress.ExpressApp.Web.Controls.XafPopupWindowControl.CreatePopupControlMarkup(String url, Boolean isSizeable, Boolean showInFindPopup, String closeScript, ClientServerInfo clientServerInfo, Frame sourceFrame, Frame targetFrame, ShowViewSource showViewSource) at DevExpress.ExpressApp.Web.PopupWindowManager.PreparePopupWindowControl(String url, Boolean isSizeable, Boolean showInFindPopup, String closeScript, Frame sourceFrame, ShowViewSource showViewSource) at DevExpress.ExpressApp.Web.PopupWindowManager.ShowPopup(String url, Boolean isSizeable, WebWindow webWindow, String callBackFuncName, Boolean forcePostBack, String targetControlId, Boolean showInFindPopup, ShowViewSource showViewSource) at DevExpress.ExpressApp.Web.PopupWindowManager.ShowPopup(PopupWindowShowAction action, Boolean isSizeable, WebWindow webWindow, String callBackFuncName, Boolean forcePostBack, String targetControlId, Boolean useFindTemplate, Boolean showInFindPopup) at DevExpress.ExpressApp.Web.Templates.ActionContainers.Menu.PopupWindowActionMenuActionItem.ExecuteAction(ASPxMenuBase menu) at DevExpress.ExpressApp.Web.Templates.ActionContainers.Menu.PopupWindowActionMenuActionItem.ProcessAction() at DevExpress.ExpressApp.Web.Templates.ActionContainers.ActionContainerHolder.ExecuteMenuItem(IList`1 items, String itemName) at DevExpress.ExpressApp.Web.Templates.ActionContainers.ActionContainerHolder.DevExpress.ExpressApp.Web.Templates.IXafCallbackHandler.ProcessAction(String parameter) at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.ProcessAction(String parameter) at DevExpress.ExpressApp.Web.Templates.XafCallbackManager.callbackControl_Callback(Object source, CallbackEventArgs e) at DevExpress.Web.ASPxCallback.OnCallback(CallbackEventArgs e) at DevExpress.Web.ASPxCallback.RaiseCallbackEvent(String eventArgument) at DevExpress.Web.ASPxWebControl.System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent(String eventArgument) InnerException is null

This scenario does not make sense and for now it is difficult to imagine why this can be required. For instance, displaying a popup from the Execute event handler in response to a user clicking the OK button would be better choice.

Would you please describe your real life use-case scenario to clarify this usage? With that, we will be able to suggest the correct technical solution as far as XAF is concerned. For now, we can only think of providing a more user-friendly exception that would help XAF developers recognize this exceptional situation and correct their custom code accordingly.

    Comments (2)

      Hi Dennis,

      How can we show a message on fly from a viewcontroller with this new ShowViewInPopupWindow function

      Dennis Garavsky (DevExpress) 8 years ago

        @Mohammed:
        Please check out the DevExpress.ExpressApp > ShowViewStrategyBase > ShowViewInPopupWindow method documentation for a code example. Should you have any specific difficulties, please submit a separate ticket with your test project using the https://www.devexpress.com/Support/Center/Question/Create service. Thanks.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.