Solved

Asp.net

Posted on 2015-02-13
9
106 Views
Last Modified: 2015-03-02
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 ,
0
Comment
Question by:Moti Mashiah
  • 5
  • 3
9 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 40609319
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
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 40609728
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
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 40609731
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
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 40609739
How are you opening the child page using Javascript or JQuery? Please post the code you are using to open the modal dialog?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:Moti Mashiah
ID: 40609751
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
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 40609895
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
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 40611282
This method "showModalDialog" is not working on chrome. when I click on the button nothing popup.
0
 
LVL 10

Accepted Solution

by:
Jini Jose earned 500 total points
ID: 40630213
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
 
LVL 1

Author Closing Comment

by:Moti Mashiah
ID: 40640176
help
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now