Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Different methods to reload/refresh page using jquery

Aug 20, 2012
Introduction

Here I will explain how to refresh or reload webpage using Jquery in asp.net.

Description:
  
In previous article I explained
expand textbox on focus and disable right click on image using JQuery and many articles relating to JQuery. Now I will explain how to refresh or reload webpage using JQuery in asp.net.

We can refresh or reload webpage in different ways

First Method

We can refresh the page by using Meta tags like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="refresh" content="10" />
<title>Refresh or reload web Page using meta tags</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
If you observe above code in header section I mentioned meta tag with http-equiv attribute this attribute will refresh the page and in that meta tag I mentioned content which is used to define time interval to refresh webpage.

First Method

We can refresh the page by using button click like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JQuery Refresh or reload web Page using asp.net</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('#btnClick').click(function() {
location.reload();
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnClick" runat="server" Text="Click" />
</div>
</form>
</body>
</html>
Third Method

Another way to refresh the page automatically using JQuery like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JQuery Refresh or reload web Page using asp.net</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
setTimeout("RefreshPage()", 10000);
})
function RefreshPage() {
location.reload();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lbltxt" runat="server"/>
</div>
</form>
</body>
</html>

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

5 comments :

Dharm said...

very nice!

Anonymous said...

Hi,

Really good for beginners. I would like to point out one thing, that you have mentioned "First Method" twice.

Arun @http://www.encodedna.com

Anonymous said...

very nice . but How to Autorefresh Particular part of a webpage using Jquery in asp.net

Saran Kumar said...

Hi Suresh,
Its very nice your all articles.
in above i have one doubt in second one in the place location what i ned to mention?
location itself or page name.

Thank you
Kumar

Neha Suman said...

Thank you so much suresh ji..
It is really heplfull..

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.