Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
Hi,

I want to display popup in page load and it should get disappear when i click outside that popup panel in asp.net.
I have tried this javascript but its working like when i click button popup will display and when i click outside the panel popup will disappear.
<style type="text/css">
        body
        {
            font-family: Arial;
            font-size: 10pt;
        }
        .modalBackground
        {
            background-color: Black;
            filter: alpha(opacity=60);
            opacity: 0.6;
        }
        .modalPopup
        {
            background-color: #FFFFFF;
            width: 300px;
            border: 3px solid #0DA9D0;
            padding: 0;
        }
        .modalPopup .header
        {
            background-color: #2FBDF1;
            height: 30px;
            color: White;
            line-height: 30px;
            text-align: center;
            font-weight: bold;
        }
        .modalPopup .body
        {
            min-height: 50px;
            line-height: 30px;
            text-align: center;
            font-weight: bold;
            margin-bottom: 5px;
        }
    </style>
<script type="text/javascript">

        function pageLoad() {
            var modalPopup = $find('mpe');
            modalPopup.add_shown(function () {
                modalPopup._backgroundElement.addEventListener("click", function () {
                    modalPopup.hide();
                });
            });
        };
    </script>
<body>
<asp:Button ID="btnShow" runat="server" Text="Button" />
<asp:Panel ID="pnlPopup" runat="server" BackColor = "LightBlue" BorderColor= "Red" style="display:none"
                    Width="466px" Height="400px"> 
             <asp:Button ID="btn" runat="server" Text="Button" />       
        
 <cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mpe"  runat="server"
        PopupControlID="pnlPopup" TargetControlID="btnShow" BackgroundCssClass="modalBackground">
    
</body>

please help me
thanks in advance
Posted

1 solution

Just above your tag add
JavaScript
<script type="text/javascript">
    pageLoad();
</script>


Or bind the function to window.onload or $(document).ready if you're using jQuery.

You made the correct method, you're just not calling it anywhere until you click.
 
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