Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dialog shows one second and closes immediately

Posted on 2012-03-29
8
Medium Priority
?
1,564 Views
Last Modified: 2012-04-04
Hello, I am using SP.UI.ModalDialog.showModalDialog. The question is that it pops out and closes immediately.

What I want is I can control the form. I can add buttons on the form. Clicking "Submit" or "Close" it to complete some kind of tasks.
 <asp:Button ID="Edit" runat="server" Text="Edit" OnClientClick="javascript:Edit_Click()">
               
            </asp:Button> 
            <script type="text/javascript">
                              function Edit_Click() {
                                  var options = SP.UI.$create_DialogOptions();

                                  options.title = "My Dialog Title";
                                  options.width = 400;
                                  options.height = 600;
                                  options.url = "/_layouts/test.aspx";
                                  options.showClose=true;
                                  SP.UI.ModalDialog.showModalDialog(options);


                              };

                </script>

Open in new window

0
Comment
Question by:zhshqzyc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 9

Expert Comment

by:BlueYonder
ID: 37781583
It is probably closing because of a post back.  Check out ajax tools, http://www.asp.net/ajaxlibrary/download.ashx,  and the modal popup.  There is an example on the page too.  You may want to put it into an updatepanel.
0
 

Author Comment

by:zhshqzyc
ID: 37781600
No, I did't use ajax at all . SP.UI.ModalDialog.showModalDialog is the new feature of SharePoint 2010.
0
 
LVL 2

Accepted Solution

by:
echefjosef earned 1500 total points
ID: 37782349
It is probably because you do not have a dialogReturnValueCallback specificed in your options.  This is the delegate that gets called on dialog close for refreshes, redirects, validatation, etc.  If you don't need to do any of this, then try adding this to your options array:

dialogReturnValueCallback: DialogCallback

Then add this in your script block:

function DialogCallback(dialogResult, returnValue) {
      //Receiver
}
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:zhshqzyc
ID: 37784265
Is it equal to return false for my function?
0
 
LVL 2

Expert Comment

by:echefjosef
ID: 37784282
No... Your function just does an unstated "return", so no value is actually passed back.  With the callback function, the close of the modal window will execute it.  It has no logic or return values either, so will just "return;" as well, rather than "return false;"
0
 

Author Comment

by:zhshqzyc
ID: 37784307
Can we use
<asp:Button ID="Edit" runat="server" Text="Edit" OnClientClick="javascript:Edit_Click(); return false;" />

Open in new window

to prevent postback?
Because it works out.
0
 
LVL 2

Expert Comment

by:echefjosef
ID: 37784402
I don't believe that would cause any issues at all... :)
0
 

Author Closing Comment

by:zhshqzyc
ID: 37806419
Maybe this is true.
But when I added return:false, It was working.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question