国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > WEB開(kāi)發(fā) > 正文

用javascript實(shí)現(xiàn)(頁(yè)面正在加載的效果)

2024-04-27 13:55:40
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

代碼文件:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.sessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Threading;
namespace AjaxTest
{
    /**//// <summary>
    /// WebForm2 的摘要說(shuō)明。
    /// </summary>
    public class WebForm2 : System.Web.UI.Page
    {
        PRotected System.Web.UI.WebControls.Button Button1;
        protected System.Web.UI.WebControls.Label Label1;
   
        private void Page_Load(object sender, System.EventArgs e)
        {
            Response.Write("<div id='mydiv' >");
            Response.Write("_");
            Response.Write("</div>");
            Response.Write("<script>mydiv.innerText = '';</script>");
            Response.Write("<script language=javascript>;");
            Response.Write("var dots = 0;var dotmax = 10;function ShowWait()");
            Response.Write("{var output; output = '正在裝載頁(yè)面';dots++;if(dots>=dotmax)dots=1;");
            Response.Write("for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText =  output;}");
            Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; ");
            Response.Write("window.setInterval('ShowWait()',1000);}");
            Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';");
            Response.Write("window.clearInterval();}");
            Response.Write("StartShowWait();</script>");
            Response.Flush();//這一句是最關(guān)鍵的
        }

        private void Button1_Click(object sender, System.EventArgs e)
        {
            //當(dāng)點(diǎn)擊按鈕時(shí),假設(shè)請(qǐng)求需要較長(zhǎng)時(shí)間(這里設(shè)置為10秒)
            System.Threading.Thread.Sleep(10000);
            this.Label1.Text = "終于加載完成啦";
        }

        Web 窗體設(shè)計(jì)器生成的代碼#region Web 窗體設(shè)計(jì)器生成的代碼
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: 該調(diào)用是 asp.net Web 窗體設(shè)計(jì)器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }
       
        /**//// <summary>
        /// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
        /// 此方法的內(nèi)容。
        /// </summary>
        private void InitializeComponent()
        {   
            this.Button1.Click += new System.EventHandler(this.Button1_Click);
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion


    }
}


頁(yè)面文件:
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="AjaxTest.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    <HEAD>
        <title>WebForm2</title>
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="Javascript">
        <meta name="vs_targetSchema" content="        <script>
         HideWait();
        </script>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            <FONT face="宋體">
                <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 480px; POSITION: absolute; TOP: 200px" runat="server"
                    Text="Button"></asp:Button>
                <asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 632px; POSITION: absolute; TOP: 240px" runat="server">Label</asp:Label></FONT>
        </form>
    </body>
</HTML>
http://fanrsh.cnblogs.com/archive/2006/06/14/425888.html


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 莱芜市| 蚌埠市| 普安县| 屯门区| 桑植县| 修武县| 柳林县| 湟中县| 虹口区| 江山市| 新宁县| 桐柏县| 怀化市| 栾川县| 锡林浩特市| 西充县| 武汉市| 霸州市| 拉萨市| 驻马店市| 松滋市| 清镇市| 寿光市| 兴义市| 临洮县| 康保县| 台南县| 上犹县| 郑州市| 三门县| 嘉黎县| 恩施市| 宁都县| 任丘市| 弥勒县| 宁安市| 灵武市| 河南省| 临桂县| 西乡县| 文山县|