[CLOSED] MessageBox with Dialog buttons, wait for answer

  1. #1

    [CLOSED] MessageBox with Dialog buttons, wait for answer

    Hello,
    I am implementing the MultiUpload Grid. I have a dialog box so when the user clicks the upload button, if file already exists, there are 3 options: "Replace", "Update Version" and "Cancel". But the program is not waiting for the answer from the MessageBox and it's keep running so I cant get the new value for txtAction.
    Second question: Is it possible to change the buttons' text? Instead of Yes, No, Cancel.
    Code Behind:
    ...
    if (sFileName1.Replace(sFileExt1, "") ==
                                            sFileName.Replace(sFileExt, ""))
                                    {
                                        X.Msg.Show(new MessageBoxConfig
                                        {
                                            Title = "File exists",
                                            Message = "Yes:Update, No:Replace, Cancel:Discard",
                                            Buttons = MessageBox.Button.YESNOCANCEL,
                                            Icon = MessageBox.Icon.QUESTION,
                                            Fn = new JFunction { Fn = "setValue" }                                      
                                        });
                                        if (txtAction.Text != null)
                                        {
                                            if (txtAction.Text == "Discard")
                                            {
                                                iFailedCnt += 1;        // NOT ALLOWING DUPLICATE.            
                                                txtAction.SetValue(null);
                                                break;
                                            }
                                        }
                                    }
    ...
    JS:

    ...var setValue = function (btn) {
                    
                    if (btn == "yes") {
                        #{txtAction}.Text == "Update";
                    }
                    else if (btn == "no") {
                        #{txtAction}.Text == "Replace";
                    }
                    else if (btn == "cancel") {
                        #{txtAction}.Text == "Discard";
                    }
    
                };
    ...
    Last edited by fabricio.murta; Jun 09, 2017 at 6:22 PM. Reason: no feedback from the user in 7+ days
  2. #2
    Hello @atroul!

    For first question, yes, but what you should do consists of effectively returning from the server (the server must check if the file already exists, right?) without doing nothing, then bind the callback for the "ok/replace" button click to send again and specifying that the upload file (or files) should be replaced. On the first attempt, a flag (or no flag) saying "don't update files -- notify" should be sent. Or rather, before the upload actually happens, a call for the server side function to check the files should be made. So that the server can reply either "yes, the file exists, show confirmation dialog" or "no, file does not exist, client-side carry on with the upload process without further userspace confirmation".

    In summary, you have to split the process in check-file and then effective send-file. And be able to throw an exception in the (maybe rare) case while somebody else uploads the file while the server is busy in the round-trip to check for file existence. Remember that's a parallel/asymmetric application thus race conditions can happen.

    For the second question, there are settings for the text displayed on each button. It is the MessageBoxButtonConfig.Text property passed via the MessageBoxButtonsConfig parameter in some MessageBox.Alert() overloads.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello @atroul!

    Been some time since we last responded you on this inquiry and so far no feedback from you. Did the reply above help at all? Do you still need help with this issue?

    We may be marking this as closed if we don't hear back from you in 7+ days. As always, this won't prevent you to post your follow-up when you feel fit even after we mark this as closed.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 2
    Last Post: Sep 09, 2011, 6:04 PM
  2. How to set the Gif for the Wait dialog
    By paddy in forum 1.x Help
    Replies: 0
    Last Post: Aug 04, 2011, 11:24 AM
  3. Replies: 3
    Last Post: Jun 10, 2011, 1:17 PM
  4. Wait cursor
    By magisystem in forum 1.x Help
    Replies: 1
    Last Post: Sep 14, 2010, 12:43 PM
  5. [CLOSED] How to wait until a DirectMethod is finished?
    By macap in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 31, 2010, 4:34 AM

Tags for this Thread

Posting Permissions