How to refresh/reload part of page using Javascript or JQuery in ASP.NET


1. Using javascript function we can able to reload part of the page. online window load we are loading startInterval function. we are reloading ShowingTime divison on every 5 seconds.

Javascript Code:
    <script type="text/javascript">
        window.onload = setInterval; //loading startInterval method onload.
        function setInterval() {
            setInterval("startTime();", 5000); 
            //for every seconds this will refresh.
        }
        function setTime() {
            document.getElementById('ShowingTime').innerHTML = Date(); 
            //changing present date based on time for every refresh.
        }
    </script>

HTML or ASP.NET Code
    <div id="ranga">
        <img src="sample.jpg" alt="ranga" />
        <div id="ShowingTime">
        this part will refresh on every 5 seconds. 
        </div>
    </div>

2. Using JQuery we can able to refresh or reload part of page. 

Javascript Code:
 <script type="text/javascript">
     window.onload = setReload;
     function setReload() {
         setInterval("reloadDivision();", 5000);
     }

     function reloadDivision() {
         $('#ReloadBlock').load("JQueryReload.aspx");
         document.getElementById('ReloadBlock').innerHTML = Date();
     }
  </script>



HTML or ASP.NET Code
   <div id="ranga">
        <img src="sample.jpg" alt="ranga" />
        <div id="ReloadBlock">
        this part will refresh on every 5 seconds. 
        </div>
    </div>


Share this post :

+ comments + 1 comments

3 May 2012 at 14:44

That is great.Thanks for contributing...

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar