Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Asp.net

Posted on 2015-02-13
9
Medium Priority
?
116 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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
 
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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
Suggested Courses

916 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