Geeks With Blogs

News

Microsoft MVP


DZone MVB


Moderator at CodeASP.NET


Quiz Master







free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer"

This example shows how to hide a Div when clicking anywhere the page:

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <title>Untitled Page</title>
     <script type=”text/javascript”>
        function HideDiv(){
             document.getElementById("ContainerDiv").style.display = 'none';
             return false;
        }

        function ShowDiv(e){
            document.getElementById("ContainerDiv").style.display = 'block';
            if(!e){
            e=window.event;
            }
            e.cancelBubble=true;
            return false;
            
        }
   </script> 
</head>

<body onclick="return HideDiv();">
    <form id="form1" runat="server">

    <asp:Button ID="Button1" runat="server" 
                Text="Show Div" OnClientClick="return ShowDiv(event);" />

      <div id="ContainerDiv"
             style="width:521px;
             height:200px;
             background-color:Gray;
             left:150px;
             position:absolute;
             top: 201px;
             display:block"
             align="center"
             onclick ="return ShowDiv(event);">

       HELLO ASP.NET
       <br />
       <asp:TextBox ID="TextBox1" runat="server" 
            onclick = "return ShowDiv(event);"></asp:TextBox>
      </div>
    </form>
</body>

</html>


That's it! I hope someone find this post useful!

 

Technorati Tags: ,,
Posted on Sunday, October 18, 2009 2:22 PM ASP.NET , JavaScript , Tips&Tricks | Back to top


Comments on this post: Hide Panel When Clicking Anywhere in the Page

comments powered by Disqus

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net