Click here to Skip to main content
15,890,995 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hi,

I would like to popup a modal dialog without close button or with close button disabled.

Is there any way to identify when the close button of a particular window is clicked?
Is there any way to do that?

thanx
Posted
Updated 9-Nov-11 22:17pm
v3
Comments
Prerak Patel 10-Nov-11 1:18am    
Why?
Vikas_Shukla_89 10-Nov-11 1:32am    
bcoz, i want to lock application when user clicks on lock <button> and no one can access that web form unless he enter correct password.

and also i want to restrict user to close that window..

is there any other way to do that?? please help.
Sergey Alexandrovich Kryukov 10-Nov-11 3:17am    
Bad idea...
--SA

If you are talking about an application modal dialog, then it's not too difficult; the instructions are here: Disable the Close box on a form.[^]
 
Share this answer
 
 
Share this answer
 
 
Share this answer
 
v2
my aim was not to close window unless user is entering correct password..
i have solved it by doing this way..

1)Window Pop Up on click of button
inside script tag--
JavaScript
function modalWin() 
{
  var WinSettings =  "dialogWidth:400px;dialogHeight:120px;titlebar=no;toolbar=no"
 var MyArgs = window.showModalDialog &quot;../Master/Unlock.aspx",WinSettings);
  if (MyArgs == null)
  {
  modalWin();
  }
  else
  {}
}

2)Ok button on newly opened window and also for when user click close button of showModalDialog box
C#
<script language=""javascript"">


                   function Done()
                   {

                   var txtenterpass = document.getElementById('<% =txtPass.ClientID %>').value; //this is where user enter password
                   txtenterpass = txtenterpass.replace(/\s+/g, "");
                   var txtstorepass = document.getElementById('<% =txtstorepass.ClientID %>').value; // this is where password is stored and we match password with above one
                    txtstorepass = txtstorepass.replace(/\s+/g, "");
                   var MyArgs = new Array(txtenterpass);
                   window.returnValue = MyArgs
                   if(window.returnValue == null)//checking for value, must not be null
                   {
                        alert('enter password');
                   }
                   else{
                   if (MyArgs == "")
                                 {
                                   alert('enter password');
                                 }
                                 else
                                 {
                                     if(txtenterpass == txtstorepass)// here we r comparing both values
                                     {
                                        window.returnValue = MyArgs;
                                         window.close();
                                     }
                                     else
                                     {
                                        document.write("Password entered is not correct");
                                     }
                                 }
                      }
                   }
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900