Ajax -- use timer to control the content background

Source: Internet
Author: User

{This content is from Microsoft}

Source viewCode:

 1   <%  @ Page Language  =  "  C #  "  Autoeventwireup  =  "  True "  Codefile  =  "  Default. aspx. CS  "  Inherits  =  "  _ Default  "    %>  
2
3 <! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
4 < Html Xmlns = "Http://www.w3.org/1999/xhtml" >
5 < Head ID = "Head1" Runat = "Server" >
6 < Title > Timer example Page </ Title >
7 < Link Href = "Divstyles.css" REL = "Stylesheet" Type = "Text/CSS" />
8 </ Head >
9 < Body >
10 < Form ID = "Form1" Runat = "Server" >
11 < ASP: scriptmanager ID = "Scriptmanager1" Runat = "Server" />
12 < ASP: Timer ID = "Timer1" Ontick = "Timereffectick" Runat = "Server" Interval = "1000" />
13 < BR />
14 < HR />
15 < BR />
16 Some content .............. < BR />
17 < BR />
18 < ASP: updatepanel ID = "Bannerpanel" Runat = "Server" Updatemode = "Conditional" >
19 < Triggers >
20 < ASP: asyncpostbacktrigger Controlid = "Timer1" />
21 </ Triggers >
22 < Contenttemplate >
23 < ASP: Image ID = "Bannerimage" Runat = "Server" Imageurl = "~ /Banners/banner_1.gif" /> & Nbsp;
24 </ Contenttemplate >
25 </ ASP: updatepanel >
26 < BR />
27 < Div >
28 & Nbsp; Some more content .......... < BR />
29 < BR />
30 </ Div >
31 </ Form >
32 </ Body >
33 </ Html >

 1     Protected     Void  Timereffectick (  Object  Sender, eventargs E)
2 {
3 Random randomclass = New Random ();
4 Int N = Randomclass. Next ( 1 , 9 );
5 Bannerimage. imageurl = System. String. Concat ( " Banners/banner _ " , N. tostring (), " . Gif " );
6 }

The function of the code is to generate an arbitrary random number from 1 to 9 to select the rendering of different images.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.