Click here to Skip to main content
15,124,736 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone, 
I need help here , It seems I missed something , when page loaded , the modal activated , and I cannot do anything .
I need to activate it (Modal ) only on some events , not all post back events.

Please help .
Thanks in advance :) 
below is my code : 



CSS
<pre>    <style type="text/css">
        .menu
        {
            font-weight: 700;
        }
        .menu
        {
            font-family: Arial;
        }
        .menu
        {
            font-size: medium;
        }
        .style1
        {
            color: #FFFFFF;
        }
        .auto-style1 {
            color: #FFFFFF;
            font-size: large;
        }
    </style>
     <style type="text/css">
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            background-color: black;
            z-index: 99;
            opacity: 0.8;
            filter: alpha(opacity=80);
            -moz-opacity: 0.8;
            min-height: 100%;
            width: 100%;
        }

        .loading {
            font-family: Arial;
            font-size: 10pt;
            border: 5px solid #67CFF5;
            width: 200px;
            height: 100px;
            display: none;
            position: fixed;
            background-color: White;
            z-index: 999;
        }
    </style>


JavaScript
<pre>         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    function ShowProgress() {
        setTimeout(function () {
            var modal = $('<div />');
            modal.addClass("modal");
            $('body').append(modal);
            var loading = $(".loading");
            loading.show();
            var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
            var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
            loading.css({ top: top, left: left });
        }, 200);
    }
    $('form').live("submit", function () {
        ShowProgress();
    });
</script>


VB
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

    If IsPostBack = False Then
        Dim script As String = "$(document).ready(function () { $('[id*=bttAdd]').click(); });"
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "load", script, True)
    End If



End Sub


What I have tried:

I tried removing these lines in page load event :
VB
If IsPostBack = False Then
          Dim script As String = "$(document).ready(function () { $('[id*=bttAdd]').click(); });"
          Page.ClientScript.RegisterStartupScript(Me.GetType(), "load", script, True)
      End If


after that all postback event fire modal .
Posted
Updated 24-Oct-21 23:46pm

1 solution

Your Javascript is using an obsolete and no-longer available jQuery method[^] to show the modal every time the form is submitted.

That means the modal will be displayed every time a post-back occurs.

If you only want to display the modal for certain events, then you need to change the Javascript code to only handle the specific events you need.

NB: Your Page_Load event appears to have nothing to do with the problem you're trying to solve.
   

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