如何刷新页面后,我进行循环(更新数据库) [英] how to refresh a page after i perform a looping(updating database)

查看:78
本文介绍了如何刷新页面后,我进行循环(更新数据库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的code,系统将执行一个循环,更新数据库的基础,它彻底更新了所有数据后,将 scriptalert 用户数据,这些数据已被更新。如何刷新页面后在 scriptalert

In my code,the system will perform a looping ,updating database base,after it completely updated all the data,it will scriptalert user,which data has been updated .how to refresh the page after the scriptalert?

推荐答案

您可以使用 location.href = location.href;显示警告信息之后。

注:在ASP.Net,你不能使用 location.reload(); 回传之后。回发将在服务器端再次触发相同的事件,和您将结束与无限循环

Note: In ASP.Net, you cannot use location.reload(); right after postback. The postback will triggers the same event again at server-side, and you will end up with infinite loop.

protected void SubmitButton_Click(object sender, EventArgs e)
{
    string script = "alert('Data was updated successfully'); location.href=location.href;";

    ClientScript.RegisterStartupScript(this.GetType(), "alert" + UniqueID, script, true);
}

AJAX页面

protected void SubmitButton_Click(object sender, EventArgs e)
{
    string script = "alert('Data was updated successfully'); location.href=location.href;";

    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert" + UniqueID, script, true);
}

这篇关于如何刷新页面后,我进行循环(更新数据库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆