提交,显示结果,延迟3秒并重定向 [英] Submit, Show Results, delay 3 seconds and redirect

查看:68
本文介绍了提交,显示结果,延迟3秒并重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,用户可以在其中输入数据,而我正在寻找的行为是在提交之后,背后的代码将写入数据库,并向页面返回成功响应.我目前正在使用此代码.我想发生的下一项是成功消息后的重定向,但我想延迟2或3秒钟,以便用户在重定向之前可以看到成功消息.

I've got a form where users can input data and the behavior that I'm looking for is after the submit, the code behind writes to a database and returns a response of success to the page. I currently have this code working. The next item that I'd like to have happen is redirect after the successful message but I'd like to delay for 2 or 3 seconds allowing the user to see the success message before redirecting.

行为:提交->显示成功消息->延迟3秒->重定向

Behavior: Submit -> Show Success Message -> Delay 3 seconds -> Redirect

我目前正在VB中进行开发;但是我可以使用VB或C#中的示例.这是传统的网络表单.

I'm currently developing this in VB; however I'm fine with examples in either VB or C#. This is a traditional web form.

推荐答案

我喜欢这种方法,尽管已经提出的一些方法非常好:

I like this approach, although some of the already proposed are very good:

protected void Button1_Click(object sender, EventArgs e)
{
    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "success", "alert('Submitted Successfully.'); setInterval(function(){location.href='http://www.google.com';},3000);", true);
}

祝你好运!

这篇关于提交,显示结果,延迟3秒并重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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