MVC服务器前台提示
[HttpPost]
public ActionResult AddMsg(MsgModel model)
{
string strSql = "insert into tbl_msg(title,msg,msg_by,msg_date,status) values(@title,@msg,@msg_by,getdate(),'A')";
SqlParameter[] paramter ={
new SqlParameter("@title",SqlDbType.NVarChar,),
new SqlParameter("@msg",SqlDbType.NVarChar,),
new SqlParameter("@msg_by",SqlDbType.VarChar,)
};
paramter[].Value = model.Title;
paramter[].Value = model.Msg;
paramter[].Value = LoginStaffID;
if (SqlDbHelper.ExecuteSql(strSql, paramter) > )
{
TempData["SuccKey"] = "添加成功,是否继续添加呢?";//前台弹出JS
}
else
{
ModelState.AddModelError("addError", "发生错误,留言失败!");//文本显示
return View(model);
}
return View();
}
<!DOCTYPE html>
<html>
<head>
<title>添加留言</title>
<link type="text/css" href="@Url.Content("~/Content/Site.css")" rel="Stylesheet" />
</head>
<body>
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>MsgModel</legend> <div class="editor-label">
@Html.LabelFor(model => model.Title)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Title)
@Html.ValidationMessageFor(model => model.Title)
</div> <div class="editor-label">
@Html.LabelFor(model => model.Msg)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Msg)
@Html.ValidationMessageFor(model => model.Msg)
</div>
用户名:@Html.DropDownList("ddlStaff_id", (SelectList)ViewBag.list, "请选择")
<p>
<input type="submit" value="添加留言" />
@Html.ValidationMessage("addError")
</p>
</fieldset>
} @if (TempData["SuccKey"]!=null)
{
<script type="text/javascript">
if (!confirm('@HttpUtility.JavaScriptStringEncode(Convert.ToString(TempData["SuccKey"]))')) {
window.location.href="Index";
}
</script>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
</body>
</html> 运行效果如下:
<form action="/Msg/AddMsg" method="post">
.......
<p>
<input type="submit" value="添加留言" />
<span class="field-validation-valid" data-valmsg-for="addError" data-valmsg-replace="true"></span>
</p>
</form>
<script type="text/javascript">
if (!confirm('添加成功,是否继续添加呢?')) {
window.location.href="Index";
}
</script>
<a href="/Msg">Back to List</a>
MVC服务器前台提示的更多相关文章
- 在mvc中弹出提示框
在传统的WebForm中,我们要弹出一个alert提示框非常简单,只要在页面中输出alert即可,比如输出: Response.Write("<script >alrer('我是 ...
- 在SharePoint 2013 场中移除服务器,提示 cacheHostInfo is null 错误
Problem 在SharePoint 2013 场中移除服务器,提示 cacheHostInfo is null 错误 Resolution 这是由于SharePoint 2013中分布式缓存实例( ...
- 开发环境运行正常,发布服务器后提示HTTP 错误 403.14 - Forbidden
一.发布服务器后报错 今天在项目发布中遇到一件奇怪的事,开发完成的项目,发布到服务器上时 1. 发布到A服务器,一切正常 2. 发布到B服务器,提示403服务器错误 在同事电脑上重新打包发布代码,并发 ...
- ssh执行远程服务器脚本 提示php: command not found
ssh执行远程服务器脚本 提示php: command not found 设置环境变量 一台机器作为管理机,来管理其他服务器,并通过key认证,免密码登陆的. 在管理机上通过ssh登陆到其他服务器来 ...
- toroiseSVN 无法连接服务器,提示unable connect to ……url 参数错误
之前使用的好好的,有天突然提示无法连接repository url,能ping通服务器,就是一直报错,找了很多方法,如: 1.删除缓存及缓存文件 2.删除软件并重新安装 3.关闭windows防火墙 ...
- MVC 服务器文件下载
文件上传到服务器后下载 window.open 与window.location.href 对txt 或是pdf文件执行的操作是打开,而非下载 mvc controller 自带有如下方法 p ...
- MVC中前台如何向后台传递数据------$.get(),$post(),$ajax(),$.getJSON()总结
一.引言 MVC中view向controller传递数据的时候真心是一个挺让人头疼的一件事情.因为原理不是很懂只看一写Dome,按葫芦画瓢只能理解三分吧. 二.解读Jquery个Ajax函数 $.ge ...
- spring mvc:exclude-mapping错误提示
今天搭建一个java web项目时,增加了一个登录的拦截器,主要功能就是未登录的用户无法访问系统的任何页面. 先说明下我的web项目springmvc的版本以及刚开始配置的拦截器: springmvc ...
- mvc jsonresult 前台、后台解析
背景介绍:asp.net中使用json对象传参;mvc中可以直接使用jsonresult这个对象 一:怎么使用jsonresult public JsonResult text() { var str ...
随机推荐
- nohup DEMO
nohup,顾名思义:挂起免疫. nohup命令可以防止当你退出系统时,在后台运行的进程被终止.它能让你运行的命令或脚本在你退出系统后继续在后台运行. nohup命令不能自动的将任务放在后台运行,所以 ...
- Caused by: javax.xml.bind.JAXBException: standardPremiumUpdateMessageDTO is not a valid property on
Caused by: javax.xml.bind.JAXBException: standardPremiumUpdateMessageDTO is not a valid property on ...
- 解决HP服务器安装Centos7 x64无法识别硬盘
公司有一台老旧的HP服务器——HP BL460c G7 SmartArray P410i.由于种种原因,需要重新安装操作系统Centos7.但是经过各种努力,Centos7的安装程序就是无法识别服务器 ...
- centos7.1-64bit安装qtcreator
首先,启用 EPEL Repository: yum -y install epel-release 启用 EPEL Repository 後, 可以用 yum 直接安裝qtcreator: yum ...
- PHP中header函数的用法及其注意重点是什么呢
1.使用header函数进行跳转页面: header('Location:'.$url); 其中$url就是将要跳转的url了. 这种用法的注意事项有以下几点: •Location和":&q ...
- hashMap底层put和get方法逻辑
1.hashmap put方法的实现: public V put(K key, V value) { if (key == null) return putForNullKey(value); int ...
- javaWeb项目命名规范
一.项目结构 这里和其他项目区别不大,我将模板抽离出来,更容易分析和理解: 解释一下:js主要包括extends(引入第三方的js).module(项目模块自己的js).lib(引用包,这里也可以继续 ...
- Educational Codeforces Round 1 A
In this problem you are to calculate the sum of all integers from 1 to n, but you should take all po ...
- VS2010常用快捷键
ctrl + K, ctrl + F 自动调整格式(选中内容) F12 转到定义 ctrl + F12 转到声明 ctrl + tab 文档窗口转换(下一个文档窗口) alt + F6 下一个面板窗口 ...
- Win8.1系统下搭建IIS8.5+php-5.6运行环境教程
本文是在window 8.1 的IIS8.5 中搭建php环境 步骤: 1.下载php-5.6程序包 ,官网地址为:http://windows.php.net/download/ 注意要下载 ...