.NET Technical bits: ASP.NET Whole Page Rendering

Tuesday, April 12, 2011

ASP.NET Whole Page Rendering

How do we refresh an ASP.NET web page to auto refresh on a set interval. Obviously, there are several methods, including Java Script.

To simply refresh the web page every five minutes, you can place the "meta http-equiv...." line shown below in the HTML editor of your ASPX page. Content ="300" means refresh every 300 seconds or five minutes.

<HEAD>
<title>WebForm1<title>

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

<meta content="C#" name="CODE_LANGUAGE">

<!--The next line of code will refresh the page every 5 minutes-->

<meta http-equiv="refresh" content="300">

<meta content="JavaScript" name="vs_defaultClientScript">

<meta content="http://schemas.microsoft.com/intellisense/ie5"

name="vs_targetSchema">

</HEAD>


That's all there is to it, if there is only a data grid on the page! However, be aware that this refresh acts like an initial page load, and any other controls, such as Drop Down Lists, etc., which have been set to other than default values will be lost unless you do some additional coding to restore their content at the time the refresh fires.

The above code will load the entire ASP page. Here it is not possible to load/refresh a particular region or control (example: data grid). Here is the need of partial rendering comes.

2 comments:

  1. This is a nice article..
    Its easy to understand ..
    And this article is using to learn something about it..

    c#, dot.net, php tutorial, Ms sql server

    Thanks a lot..!
    ri70

    ReplyDelete