asp.net mvc跳转提示实现
2015-02-12 11:18
603 查看
在执行完操作后往往需要显示执行的结果,可以使用js来实现执行后跳转并显示信息的功能。
视图
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>跳转提示</title>
</head>
<body>
<div class="system-message">
<h1>@ViewBag.Redirect["message"]</h1>
<p class="jump">
页面自动 <a id="href" href="@ViewBag.Redirect["url"]">跳转</a> 等待时间: <b id="wait">@ViewBag.Redirect["time"]</b>
</p>
</div>
<script type="text/javascript">
(function () {
var wait = document.getElementById('wait'), href = document.getElementById('href').href;
var interval = setInterval(function () {
var time = --wait.innerHTML;
if (time <= 0) {
location.href = href;
clearInterval(interval);
};
}, 1000);
})();
</script>
</body>
</html>
跳转数据
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EditorOnline.Util
{
public class RedirectData
{
public static Dictionary<String, Object> GetSuccess(String url, String message)
{
return GetRedirect(url, message, 2);
}
public static Dictionary<String, Object> GetRedirect(String url, String message, int time)
{
Dictionary<String, Object> dic = new Dictionary<string, object>();
dic.Add("url", url);
dic.Add("message", message);
dic.Add("time", time);
return dic;
}
public static Dictionary<String, Object> GetFail(String url, String message)
{
return GetRedirect(url, message, 3);
}
}
}
跳转功能
/// <summary>
/// 页面跳转视图
/// </summary>
/// <param name="url"></param>
/// <param name="message"></param>
/// <param name="time"></param>
/// <returns></returns>
protected ViewResult Redirect(String url, String message, int time)
{
this.ViewBag.Redirect = RedirectData.GetRedirect(url, message, time);
return this.View("redirect");
}调用示例
return Redirect("/Home/Index", "执行成功", 2);在需要跳转的控制器中使用
视图
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>跳转提示</title>
</head>
<body>
<div class="system-message">
<h1>@ViewBag.Redirect["message"]</h1>
<p class="jump">
页面自动 <a id="href" href="@ViewBag.Redirect["url"]">跳转</a> 等待时间: <b id="wait">@ViewBag.Redirect["time"]</b>
</p>
</div>
<script type="text/javascript">
(function () {
var wait = document.getElementById('wait'), href = document.getElementById('href').href;
var interval = setInterval(function () {
var time = --wait.innerHTML;
if (time <= 0) {
location.href = href;
clearInterval(interval);
};
}, 1000);
})();
</script>
</body>
</html>
跳转数据
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace EditorOnline.Util
{
public class RedirectData
{
public static Dictionary<String, Object> GetSuccess(String url, String message)
{
return GetRedirect(url, message, 2);
}
public static Dictionary<String, Object> GetRedirect(String url, String message, int time)
{
Dictionary<String, Object> dic = new Dictionary<string, object>();
dic.Add("url", url);
dic.Add("message", message);
dic.Add("time", time);
return dic;
}
public static Dictionary<String, Object> GetFail(String url, String message)
{
return GetRedirect(url, message, 3);
}
}
}
跳转功能
/// <summary>
/// 页面跳转视图
/// </summary>
/// <param name="url"></param>
/// <param name="message"></param>
/// <param name="time"></param>
/// <returns></returns>
protected ViewResult Redirect(String url, String message, int time)
{
this.ViewBag.Redirect = RedirectData.GetRedirect(url, message, time);
return this.View("redirect");
}调用示例
return Redirect("/Home/Index", "执行成功", 2);在需要跳转的控制器中使用
相关文章推荐
- asp.net mvc当出现错误时如何实现友好错误提示
- ASP.NET MVC中如何实现页面跳转
- Asp.net实现网站提示信息页面后的定时自动跳转到指定页面
- asp.net mvc实现图片下载防盗链及提示是否存在!
- Asp.net 中mvc 实现超时弹窗后跳转功能
- 关于ASP.NET MVC框架的代码提示汉化实现方法
- 记录:asp.net mvc 中 使用 jquery 实现html5 实现placeholder 密码框 提示兼容password IE6
- ASP.NET MVC中Action实现页面跳转
- asp.net 2.0 ajax中实现弹出窗口报警提示
- Asp.net实现弹出窗口提示,又防止刷新被重复提交的方法
- 在asp.net中实现删除DataGrid的某条记录时的提示信息
- 在Asp.net中如何实现弹出提示对话框
- 在Asp.net中如何实现弹出提示对话框()
- 在Asp.net中如何实现弹出提示对话框
- ASP.NET中实现模型-视图-控制器(MVC)模式
- asp.net 2.0中实现弹窗报警提示
- asp.net 2.0 ajax中实现弹出窗口报警提示
- Asp.net中实现页面跳转的三种方法比较
- 在Asp.net中如何实现弹出提示对话框
- 在Asp.net中如何实现弹出提示对话框