当前位置:编程学习 > C#/ASP.NET >>

ASP用局部刷新UpdatePanel问题

用UpdatePanel进行局部刷新,但是在chrome浏览器下会有很明显的刷新痕迹。
我想做的是一个报警系统。数据库表中扫描,如果有符合的进行定时刷新,没有符合的就不刷新。
时间间隔是1秒。
IE没有问题,但是chrome就是每秒图标会跳一下。
<asp:UpdatePanel ID="Warnningupdate" runat="server"  >
        <ContentTemplate>
        <asp:Image ID="No1warning" runat="server" ImageUrl="~/pic/warnning.png" style="background-color:transparent;margin-left:95px"/>
        </ContentTemplate>
    </asp:UpdatePanel>


public void getwanninglight()
        {
            
            No1warning.ImageUrl = "~/pic/normal.png";
            No2warning.ImageUrl = "~/pic/normal.png";
            No3warning.ImageUrl = "~/pic/normal.png";
            No4warning.ImageUrl = "~/pic/normal.png";
            No5warning.ImageUrl = "~/pic/normal.png";
            No6warning.ImageUrl = "~/pic/normal.png";
            No7warning.ImageUrl = "~/pic/normal.png";
            No8warning.ImageUrl = "~/pic/normal.png";
            No9warning.ImageUrl = "~/pic/normal.png";
           
            String sqlconnection = ConfigurationManager.ConnectionStrings["suidaozhaomingConnectionString"].ToString();
            String Sqlwarnningcount = "select count(1) from warnning_info";
            SqlConnection conn = new SqlConnection(sqlconnection);
            SqlCommand comm = new SqlCommand(Sqlwarnningcount, conn);
            conn.Open();
            int num = Convert.ToInt32(comm.ExecuteScalar().ToString());
            conn.Close();
            if (num > 0)
            {
                String Sqlwarnninginfo = "select suidao_code from warnning_info";
                SqlCommand warnningget = new SqlCommand(Sqlwarnninginfo, conn);
                string[] warningsuidao = new string[9];
                conn.Open();
                SqlDataReader suidaowarning_info = warnningget.ExecuteReader();
                int i = 0;
                while (suidaowarning_info.Read() == true)
                {
                    warningsuidao[i] = suidaowarning_info["suidao_code"].ToString();
                    i++;
                }
                conn.Close();
                for (int j=0; j < 9; j++)
                {
                    if(warningsuidao[j] == suidaoread[0,1])
                    {
                        No1warning.ImageUrl = "~/pic/warn.png";
                        
                    }
                    else if (warningsuidao[j] == suidaoread[1, 1])
                    {
                        No2warning.ImageUrl = "~/pic/warn.png";
                       
                    }
                    else if (warningsuidao[j] == suidaoread[2, 1])
                    {
                        No3warning.ImageUrl = "~/pic/warn.png";
                      
                    }
                    else if (warningsuidao[j] == suidaoread[3, 1])
                    {
                        No4warning.ImageUrl = "~/pic/warng.png";
                       
                    }
                    else if (warningsuidao[j] == suidaoread[4, 1])
                    {
                        No5warning.ImageUrl = "~/pic/warn.png";
                       
                    }
                    else if (warningsuidao[j] == suidaoread[5, 1])
                    {
                        No6warning.ImageUrl = "~/pic/warn.png";
                        
                    }
                    else if (warningsuidao[j] == suidaoread[6, 1])
                    {
                        No7warning.ImageUrl = "~/pic/warn.png";
                        
                    }
                    else if (warningsuidao[j] == suidaoread[7, 1])
                    {
                        No8warning.ImageUrl = "~/pic/warn.png";
                       
                    }
                    else if (warningsuidao[j] == suidaoread[8, 1])
                    {
                        No9warning.ImageUrl = "~/pic/warn.png";

                    }
                    else
                    {
                      
                    }


有没有办法写成触发器形式的。就是先查下count,如果>0就刷新,不然就不动 --------------------编程问答-------------------- --------------------编程问答-------------------- 额,发现很奇怪,用vs调试会闪,但是用IIS发布以后这个问题有时有,有时无。求问题原因 --------------------编程问答-------------------- 你用一个button事件来执行这个public的方法
然后把button的id放在updatepanel的trigger里面
updatepanel添加属性 UpdateMode="Conditional"
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,