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 ...
随机推荐
- python sklearn环境配置
os:win10 python2.7 主要参照 1.现下载pip.exe,因为很多安装文件都变成whl格式了,这里要注意下载对应python版本的,要用管理员权限,可以参照https://pypi ...
- MySQL对于数据库应该如何如何配置安全问题了
mysql 是完全网络化的跨平台关系型数据库系统,同时是具有客户机/服务器体系结构的分布式数据库管理系统.它具有功能强.使用简便.管理方便.运行速度快.安全可靠性强等优点,用户可利用许多语言编写访问m ...
- java 面试每日一题6
题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? 1.程序分析: 兔子的规律为数列1,1,2,3,5 ...
- java面试每日一题5
题目:企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高于10万元,低于20万元时,低于10万元的部分按10%提 成,高于10万元的部分,可可提成7.5%:20万到40 ...
- android中广告轮播图总结
功能点:无限轮播.指示点跟随.点击响应.实现思路: 1.指示点跟随,指示点通过代码动态添加,数量由图片数量决定. 在viewpager的页面改变监听中,设置点的状态选择器enable,当前页时,set ...
- 【转】MYSQL入门学习之十一:触发器的基本操作
转载地址:http://www.2cto.com/database/201212/176781.html 触发器是MySQL响应以下任意语句而自动执行的一条MySQL语句(或位于BEGIN和END语句 ...
- 【转】MYSQL入门学习之六:MYSQL的运算符
转载地址:http://www.2cto.com/database/201212/175862.html 一.算术运算符 1.加 www.2cto.com mysql> s ...
- A类地址
一个A类IP地址由1字节(每个字节是8位)的网络地址和3个字节主机地址组成,网络地址的最高位必须是“0”.A类IP的地址第一个字段范围是0~127,但是由于全0和全1的地址用作特殊用途,实际可指派的第 ...
- SDUT 2623:The number of steps
The number of steps Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Mary stands in a stra ...
- Design T-Shirt 分类: HDU 2015-06-26 11:58 7人阅读 评论(0) 收藏
Design T-Shirt Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...