Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi. friends, I have a web page in my .net application, my problem is that, I have a querysting mn in the page url. My condition is that when mn=0 here is not any message when closing the browser but when mn>0 then here is a message to "Are u sure to close this page".

If any body have some idea about this, please help me.

Thanks & Regards

Parveen Rathi
Posted
Comments
[no name] 4-Jun-12 3:12am    
should you use javascript in your page

C#
if(Convert.ToInt32(Request.QueryString["mn"])>0)
            {
                Button1.Attributes.Add("onclick", "confirm('Are you sure')");
            }
 
Share this answer
 
XML
<script  type ="text/javascript" language ="javascript"  >

function unload()
    {

       var Flg= document.getElementById('hdn');
        if (parseInt(Flg.value)>0)
        {
            event.returnValue = "Are u sure to close this page";
        }
    }
</script>

<body  onbeforeunload="unload()" onload ="AutoSave()"  >
    <form id="form1" runat="server"  >

<asp:HiddenField ID="hdn" runat="server" />


on page load add value of querry string to this hidden field



it will work
 
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