zoukankan      html  css  js  c++  java
  • 也学ASP.NET 2.0 AJAX 之二:使用Timer控件

    时钟控件介绍
    这次你将使用Microsoft ASP.NET 2.0 AJAX Extensions服务器控件:ScriptManager、UpdatePanel、Timer来更新页面中的一部分。添加这些控件到一个页面上限制每次回调便更新整个页面。只有UpdatePanel控件内容将会被更新。
    1.创建一新页面,转到设计视图
    2.如果页面没有ScriptManager控件,就在AJAX Extensions工具箱面板上双击它添加到页面上
    3.加入UpdatePanel控件
    4.单击UpdatePanel控件内部,再双击Timer控件添加到UpdatePanel控件上(timer要放在UpdatePanel内部)
    5.设置Timer控件Interval属性为10000(10秒)
    6.拖入一个标准Label到UpdatePanel控件上
    7.设置Label的Text属性为“Panel not refreshed yet.”
    8.拖放第二个Label到UpdatePanel控件外面
    9.设置Timer控件的Tick事件
    10.设置Page_Load事件
    代码如下:
        protected void Page_Load(object sender, EventArgs e)
        {
            Label2.Text = "Page created at: " +
              DateTime.Now.ToLongTimeString();
        }
        protected void Timer1_Tick(object sender, EventArgs e)
        {
            Label1.Text = "Panel refreshed at: " +
              DateTime.Now.ToLongTimeString();
        }
    运行

  • 相关阅读:
    5.1.5 JunkMail Filter
    POJ1067 取石子游戏 跪跪跪,很好的博弈论
    USACO Section 3.2 Magic Squares (msquare)
    5.1.1 A Bug's Life
    USACO Section 3.3 Riding The Fences (fence)
    USACO Section 3.1 Stamps (stamps)
    5.2.7 Entropy
    USACO Section 3.1 AgriNet (agrinet)
    5.1.8 How Many Answers Are Wrong
    4.3.6 N皇后问题
  • 原文地址:https://www.cnblogs.com/yansc/p/635406.html
Copyright © 2011-2022 走看看