Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Help please,


I want to display messagebox whenever user clicks on page except on one button click. (This page is the child page to one master page ). we are trying in the events of page but i am not getting the result.
Posted
Updated 22-Jan-14 18:03pm
v2
Comments
JoCodes 23-Jan-14 0:18am    
Can you show what you tried?

get it done by jquery

JavaScript
$(document).click(function() {
    alert("you clicked");
});
 
Share this answer
 
Comments
sravantarun 23-Jan-14 0:06am    
Thank you for the reply. i am getting exception as "JavaScript runtime error: '$' is undefined". sorry to say that i didnt give clear explanation regarding the question. i updated it now kindly check that now
Karthik_Mahalingam 23-Jan-14 0:54am    
add jquery reference to it
Try

C#
protected void Button1_Click(object sender, EventArgs e)
        {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Message')", true);

        }
 
Share this answer
 
Try this..

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="jquery-1.10.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        var clickpage = function () {
            document.getElementById('btn').onclick = function () {
                document.onclick = function () {
                    return false;
                }
            };
            document.onclick = function () {
                alert('clicked');
            }

        }
    </script>
</head>
<body onload="clickpage()">
    <form id="form1" runat="server">
    <asp:Button Text="text" ID="btn" runat="server" />
    </form>
</body>
</html>
 
Share this answer
 
Comments
sravantarun 23-Jan-14 1:21am    
can we achive this from .cs file??
Karthik_Mahalingam 23-Jan-14 1:24am    
y not

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