解决方案 »
- Gridview 中编辑列问题
- 在asp.net 中 如何在登录成功后自动跳转到登录前的页面
- 新手,如何开发一个通知公告模块,第一次编程,请大家指教。
- showModalDialog弹出的窗口如何关闭
- 【【【【难呀高手帮帮我呀...】】】】
- FreeTextBox使用出错了啊
- 时间的转化载入数据库的问题
- 看看这段 virtual 的 代码 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 碰到一个奇怪的问题,用sqlDataAdapter1.Update更新不行
- 关于数据传输的问题?
- <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 在ie11不管用
- js获取不到get方法 post方法 的返回值
{
// rp.AddViedo(myVideo); 具体操作
return Json("");
}
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
@using(Html.BeginForm())
{
@Html.TextAreaFor(model=>model.time)
@Html.TextAreaFor(model=>model.en)
@Html.TextAreaFor(model=>model.cn)
<input id="save" type="submit" value="submit" />
}
public ActionResult Index( )
{
return View();
}
[HttpPost]
public ActionResult Index(Video v)
{
string time = v.time;
string en = v.en;
string cn = v.cn;
return Json("json数据");
}
MVC项目经验我也只有半年左右,但据我所知上面是最常用的操作流程
楼主想通过data: JSON.stringify(myVideo) 方式提交应该是data:{"K":"V"},cs中通过Request对象找到K对应的json(V)在解析为Video。
{
if(myVideo.cn == null) myVideo.cn = string.Empty;
// rp.AddViedo(myVideo); 具体操作
return null;
}
哈哈自己搞定了,就是给属性增加 [DisplayFormat( ConvertEmptyStringToNull = false )] [DisplayFormat( ConvertEmptyStringToNull = false )]
要是不添加这个属性,一旦view页面的传递""过来,框架会自动把空字符转换为null
DisplayFormatAttribute.ConvertEmptyStringToNull属性:是否将空字符串值 ("") 自动转换为null.默认值为 true
http://msdn.microsoft.com/zh-cn/library/vstudio/system.componentmodel.dataannotations.displayformatattribute.convertemptystringtonull(v=vs.100).aspx