[RESOLVED]jquery loading

I have this function in the server side that calls the function draw from javascript on pageload event. the function is called based on a condition , how i can add a loading image to my code when calling this function only?

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                 if(condition==true) // x some condition
                 {
                ClientScript.RegisterStartupScript(GetType(), "id", "setTimeout(draw,5000);", true);
                   }
 
            }
        }

Hi Sanfoor ,

For your issue ,below are my suggestion,you can add a hide function to your javascript to hide the image. just like below:

   <script type="text/javascript">
       function draw() {
     
           $(".loader").fadeOut(1000);

       }

       function hide() {
           $(".loader").hide();
       }

   </script>
<div class="loader"></div>

The div container a image.

Then you can try the code server side below:

  if (condition==true)
                {
                    ClientScript.RegisterStartupScript(GetType(), "id", "setTimeout(draw,5000);", true);
                }
                else {
                    ClientScript.RegisterStartupScript(GetType(), "hide", "hide();", true);
                }

Best Regards,

Kevin Shen.

Leave a Reply