功能:
    起定时器作用。
重要属性:
    Interval :间隔时间。(单位:毫秒。3000即为3秒)
实例代码:
 功能: 定时显示图片
Timer的控件使用<html xmlns="http://www.w3.org/1999/xhtml">
Timer的控件使用
<head id="Head1" runat="server">
Timer的控件使用    
<title>Timer Example Page</title>
Timer的控件使用    
<link href="DivStyles.css" rel="stylesheet" type="text/css" />
Timer的控件使用
</head>
Timer的控件使用
<body>
Timer的控件使用    
<form id="form1" runat="server">
Timer的控件使用    
<asp:ScriptManager ID="ScriptManager1" runat="server" />
Timer的控件使用        
<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="3000" />
Timer的控件使用        
<br />
Timer的控件使用        
<hr />
Timer的控件使用        
<br />
Timer的控件使用        Some content Timer的控件使用Timer的控件使用Timer的控件使用Timer的控件使用..
<br />
Timer的控件使用        
<br />
Timer的控件使用
Timer的控件使用        
<asp:UpdatePanel ID="BannerPanel" runat="server" UpdateMode="Conditional">
Timer的控件使用        
<Triggers>
Timer的控件使用            
<asp:AsyncPostBackTrigger ControlID="Timer1" />
Timer的控件使用        
</Triggers>
Timer的控件使用        
<ContentTemplate>
Timer的控件使用            
<asp:Image ID="BannerImage" runat="server" ImageUrl="~/banners/banner_1.gif" />&nbsp;
Timer的控件使用        
</ContentTemplate>
Timer的控件使用        
</asp:UpdatePanel>
Timer的控件使用        
<br />
Timer的控件使用        
<div>
Timer的控件使用            
&nbsp;Some more content Timer的控件使用Timer的控件使用Timer的控件使用.<br />
Timer的控件使用            
<br />
Timer的控件使用        
</div>
Timer的控件使用    
</form>
Timer的控件使用
</body>
Timer的控件使用
</html>
Timer的控件使用
后台代码如下:
Timer的控件使用 protected void Timer1_Tick(object sender, EventArgs e)
    }

DivStyles.css样式如下:

}

再在工程下建立一下banners文件夹,在里面放入banners_1.gif,banner_2.gif,.......等图片。

运行结果:每隔3秒会显示不同的图片。
    Timer的控件使用


 

相关文章: