Summary of the method for step by step rendering of the asp.net page
- 2020-05-10 17:57:10
- OfStack
For details, please refer to: flush makes the page block and render step by step
Suppose you have a page that displays the logo icon for cnblogs at the beginning, and the logo icon for csdn at the end of 3 seconds.
I implemented the above functions with asp.net based on the above introduction.
ASP. NET code is as follows:
If you want to achieve the effect of lazy loading of tudou.com home image, you can easily use jquery.
For more details, please refer to: technical analysis of the website - a brief discussion on the effect of lazy loading of tudou.com homepage pictures
The JQuery code is as follows:
Suppose you have a page that displays the logo icon for cnblogs at the beginning, and the logo icon for csdn at the end of 3 seconds.
I implemented the above functions with asp.net based on the above introduction.
ASP. NET code is as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="flush Let the page be rendered in chunks .aspx.cs" Inherits="Web_1.flush Let the page be rendered in chunks " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>flush Let the page be rendered in chunks </title>
</head>
<body>
<div id="head" style="border:1px solid #ccc;">
cnblogs logo <img src="http://images.cnblogs.com/logo_small.gif" alt=""/>
</div>
<%
// flush Block output
Response.BufferOutput = false;
Response.Flush();
// Response.Output.Flush();
%>
<br /> 3 Load the following in seconds ...
<div id="content" style="border:1px solid blue;">
<%
// sleep 3 seconds
System.Threading.Thread.Sleep(3000);
%>
csdn logo <img src="http://csdnimg.cn/www/images/csdnindex_piclogo.gif" alt=""/>
</div>
</body>
</html>
If you want to achieve the effect of lazy loading of tudou.com home image, you can easily use jquery.
For more details, please refer to: technical analysis of the website - a brief discussion on the effect of lazy loading of tudou.com homepage pictures
The JQuery code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
</head>
<body>
1 Images to start with:
<img src="http://at-img4.tdimg.com/board/2010/5/tylc-115X55.jpg"/>
<div id="lazyBox" style="margin-top:100px;">
1 At first you can't see the following image, but when you scroll you can:
<img width="120" height="90" style="border:1px solid blue;" class="lazyImg" alt="http://i01.img.tudou.com/data/imgs/i/051/871/396/m20.jpg" src="http://css.tudouui.com/skin/__g/img/sprite.gif" coords="_DBA"/>
</div>
<div style="height:1000px;"></div>
<script type="text/javascript">
var hasShow = false;
$(window).bind("scroll",function(){
if(hasShow==true){
$(window).unbind("scroll");
return;
}
var t = $(document).scrollTop();
if(t>50){
// Rolling height over 50 , load the picture
hasShow = true;
$("#lazyBox .lazyImg").each(function(){
$(this).attr("src",$(this).attr("alt"));
});
}
});
</script>
</body>
</html>