.NET --- 页面刷新(html 和 js两种方式)

1、使用HTML <meta> 标签,中的 http-equiv 属性

经过一段时间转到另外某个页面
<
meta http-equiv="refresh[刷新-这里指定动作]" content="5[这里是时间];url=/obge[这里是跳转的URL]">

如果只是一段时间刷新本界面,可以不使用 url 属性

页面定期刷新,如果加url的,则会重新定向到指定的网页,content后面跟的是时间(单位秒)

 

2、借助js 进行页面刷新,借助  setTimeout() 方法

    <script type="text/javascript">

        function myrefresh() {
            document.getElementById("<%=btnclick.ClientID%>").click();
            setTimeout('myrefresh()', 1000);
        }
    </script>

 

3、也可只在局部刷新使用,具体

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExcelMessage.aspx.cs" Inherits="qdAdmin_qdExcel_Excel_ExcelMessage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <%--    <meta http-equiv="refresh" content="1" />--%>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <script type="text/javascript">

        function myrefresh() {
            document.getElementById("<%=btnclick.ClientID%>").click();
            setTimeout('myrefresh()', 1000);
        }
    </script>

    <title></title>
</head>
<body style="background-color: white;" onload="myrefresh()">
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

        <div>

            <font color="red">请停止一切操作,直至数据操作完毕!</font>
            <hr size="1" />

            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Button ID="btnclick" runat="server" Text="..." />
                    <%=base.ExcelUpLoadMessage %>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>

    </form>
</body>
</html>

赋值

    private void GetChange()
    {



        while (true)
        {
            string strsql1 = "select count(*) from tbmdGongZiList where QiyeGuid='" + xEnterpriseGuid + "' and GongZiGuid='" + _GongZiGuid_new + "'";
            string strsql2 = "select count(*) from tbmdGongZiList where QiyeGuid='" + xEnterpriseGuid + "' and GongZiGuid='" + _GongZiGuid_old + "'";

            object obj1 = _bllGongZiList.GetScalarByTx(strsql1);
            object obj2 = _bllGongZiList.GetScalarByTx(strsql2);
            if (obj1 != DBNull.Value && obj2 != DBNull.Value)
            {
                base.ExcelUpLoadMessage = "当前正在复制:" + obj1.ToString() + " / " + obj2.ToString();
            }
            else
            {
                return;
            }

            if (obj1 == obj2)
            {
                base.ExcelUpLoadMessage = "复制运算完毕,共更新了" + obj1.ToString() + "条数据,点击这里返回<input type=\"button\" onclick=\"javascript: window.history.back()\" value=\"返回\"/> ";
                return;
            }
        }
    }

 

posted on 2020-07-09 16:20  obge  阅读(402)  评论(0编辑  收藏  举报