当前位置: 代码迷 >> ASP.NET >> 在label中提示更新数据成功后,暂停几秒重定向解决思路
  详细解决方案

在label中提示更新数据成功后,暂停几秒重定向解决思路

热度:9003   发布时间:2013-02-25 00:00:00.0
在label中提示更新数据成功后,暂停几秒重定向
更新操作在后台判断,如果成功,则在Updatepanel中的一个label控件中显示数据更新成功,本来想让系统sleep几秒后,重定向,但是如果加上System.Threading.Thread.Sleep(3000);后,label.text中并不会显示“数据更新成功”,请问如何解决?

代码大致是这样的:
C# code
                        if (congshuBll.Updatecongshu(bpmcongshu) > 0)                        {                            lblMsg.Text = "<span style=\"color: green\">更新丛书成功!</span>";                            System.Threading.Thread.Sleep(2000);                            Response.Redirect("congshumanage.aspx?ID=" + bpmcongshu.IDinCategory.ToString());                        }




------解决方案--------------------------------------------------------
用ajax控件Timer,或者用js定时器。
------解决方案--------------------------------------------------------
换个方式思考一下,干嘛非要用lable提示某操作已经ok???

试试这个:

C# code
        Response.Write("<script>window.alert('maopianjijiangkaishi...')</script>");        Response.Write("<script>window.location ='http://www.baidu.com'</script>");
------解决方案--------------------------------------------------------
C# code
if (congshuBll.Updatecongshu(bpmcongshu) > 0)                        {                            lblMsg.Text = "<span style=\"color: green\">更新丛书成功!</span><script>window.setTimeout(function(){window.location.href='http://www.370b.com'},2000)</script>";                                                    }
  相关解决方案