Asp.net

Hi guys ,

I'm working on asp.net mvc application and i would like to do the following:

I want to disable the window browser close(X) while I am opening my ModalDialog box.


thanks ,
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?
 
Jini JoseConnect With a Mentor Senior .Net DeveloperCommented:
you can use a simple javascript method.

<script language="JavaScript">
  var needToConfirm = true;

  window.onbeforeunload = confirmExit;
  function confirmExit()
  {
    if (needToConfirm)
      return message to display in dialog box;
  }
</script>

Open in new window


for more details go the below link
http://stackoverflow.com/questions/1565304/jquery-prevent-window-closing
0
 
Paul JacksonSoftware EngineerCommented:
You can't disable the close button on a browser window for security reasons, such as malicious pop-ups on web sites trying to get you to click a button and install a virus or trojan without closing the window.
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
I missed understand the solution.

I will explain the situation again:

when users work on the main page they click on button which popup for them another webpage. what i would like to do is in a while user work on the popup page they can't close the main page.

Thanks ,
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Moti Mashiah.NET DeveloperAuthor Commented:
I have another comment which will explain it much better :)

when I open child page I want to prevent from users to close the parent page. The users will be able to close the parent page just when they close the child page first.


Thanks ,
0
 
Paul JacksonSoftware EngineerCommented:
How are you opening the child page using Javascript or JQuery? Please post the code you are using to open the modal dialog?
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
this is the javascript:

 function picCatalog() {
            var url = "@System.Configuration.ConfigurationManager.AppSettings["webUrl"]";
            url = url + "Altstorepo/Index";
            window.open(url, '_blank', 'resizable=yes');
        }

Open in new window

0
 
Paul JacksonSoftware EngineerCommented:
Use the window.showModalDialog() javascript function instead:

window.showModalDialog(url,'_blank','resizable=yes');

Open in new window


However to future-proof your code you should really investigate using jquery dialogs which provide an option to make dialogs modal.
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
This method "showModalDialog" is not working on chrome. when I click on the button nothing popup.
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.