求助MVC4 修改个人信息submit,没有post到Modify方法
求大神帮助!! 
修改个人信息 部分字段
表现: 修改个人信息点击save,原本应该跳转到Index.cshtml,但只在原页面刷新了一下,数据没有更改。
已经把RetireeModel的验证去掉了,自己测试了一下是感觉Modify没有进去,点击save,没有post到Modify方法
也测试用了其他字段比较少的Model,修改后save居然是可行的!! 也不知道是不是RetireeModel字段比较多的原因? 求解!
这是view 代码
这是controllor 代码
这是Model

修改个人信息 部分字段
表现: 修改个人信息点击save,原本应该跳转到Index.cshtml,但只在原页面刷新了一下,数据没有更改。
已经把RetireeModel的验证去掉了,自己测试了一下是感觉Modify没有进去,点击save,没有post到Modify方法
也测试用了其他字段比较少的Model,修改后save居然是可行的!! 也不知道是不是RetireeModel字段比较多的原因? 求解!

这是view 代码
@model MvcSilverTalent.Models.RetireeModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Edit</title>
</head>
<body>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>RetireeModel</legend>
@Html.HiddenFor(model => model.RetireNum)
<div class="editor-label">
@Html.LabelFor(model => model.Specialty)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Specialty)
@Html.ValidationMessageFor(model => model.Specialty)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Address)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Address)
@Html.ValidationMessageFor(model => model.Address)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.HomeTel)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.HomeTel)
@Html.ValidationMessageFor(model => model.HomeTel)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.MobileNum)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.MobileNum)
@Html.ValidationMessageFor(model => model.MobileNum)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.ZipCode)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ZipCode)
@Html.ValidationMessageFor(model => model.ZipCode)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Email)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Email)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
</body>
</html>
这是controllor 代码
//
// GET: /UserInfo/Edit.cshtml
public ActionResult Edit(int RetireNum)
{
RetireeModel RetireeModel = db.RetireeModels.Find(RetireNum);
if (RetireeModel == null)
{
return HttpNotFound();
}
return View(RetireeModel);
}
//
// POST: /UserInfo/Edit.cshtml
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Modify(RetireeModel RetireeModel)
{
Response.Write("<script>alert('dddd')</script>"); // 没有运行这句话
if (ModelState.IsValid)
{
db.Entry(RetireeModel).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
Response.Write("<script>alert('xxxx')</script>"); // 没有运行这句话
return View(“Index”); // 也没有跳转到Index.cshtml,只是在原页面刷新了一下,数据没有更改
}
这是Model
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
namespace MvcSilverTalent.Models
{
public class RetireeModel
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int RetireNum { get; set; }
[Required]
[DisplayName("单位编号")]
[MaxLength(3)]
public string UnitID { get; set; }
[Required]
[DisplayName("员工编号")]
[MaxLength(6)]
public string EmployeeID { get; set; }
[Required]
[DisplayName("离退休类型")]
public int RetireType { get; set; }
[Required]
[DisplayName("删除标记")]
public int DeleteFlag { get; set; }
//
// 基本信息
[Required]
[DisplayName("姓名")]
[MaxLength(20)]
public string Name { get; set; }
[Required]
[DisplayName("性别")]
public Boolean Gender { get; set; }
[Required]
[DisplayName("身份证号码")]
public string IDCardNo { get; set; }
[Required]
[DisplayName("出生年月")]
public DateTime Brityday { get; set; }
[Required]
[DisplayName("民族")]
[MaxLength(30)]
public string Nationality { get; set; }
[Required]
[DisplayName("籍贯")]
[MaxLength(30)]
public string NativePlace { get; set; }
[DisplayName("党派")]
[MaxLength(30)]
public string Party { get; set; }
[DisplayName("所在党支部")]
[MaxLength(100)]
public string PartyBranch { get; set; }
[DisplayName("最高学历")]
[MaxLength(20)]
public string EducationDegree { get; set; }
[Required]
[DisplayName("用户组")]
public string GroupName { get; set; }
[Required]
[DisplayName("是否参加爱心基金")]
public Boolean HasLoveFund { get; set; }
[DisplayName("享受爱心基金慰问情况")]
public string LoveFundCase { get; set; }
[DisplayName("慰问走访情况")]
public string VisitCase { get; set; }
//
// 工作信息
[Required]
[DisplayName("参加工作时期")]
public int WorkPeriod { get; set; }
[Required]
[DisplayName("参加工作时间")]
public DateTime WorkTime { get; set; }
[Required]
[DisplayName("退休时间")]
public DateTime RetireTime { get; set; }
[Required]
[DisplayName("工龄")]
public int WorkAge { get; set; }
[Required]
[DisplayName("退休单位")]
[MaxLength(100)]
public string UnitName { get; set; }
[DisplayName("职称代码")]
[MaxLength(3)]
public int TitleID { get; set; }
[DisplayName("职称")]
[MaxLength(30)]
public string Title { get; set; }
[DisplayName("职务")]
[MaxLength(30)]
public string Position { get; set; }
[DisplayName("编制")]
[MaxLength(30)]
public string Formation { get; set; }
//
// 可修改信息
[Required]
[MaxLength(255)]
[DisplayName("近照")]
public string PhotoUrl { get; set; }
[MaxLength(255)]
[DisplayName("特长")]
public string Specialty { get; set; }
[Required]
[MaxLength(255)]
[DisplayName("现住地址")]
public string Address { get; set; }
[MaxLength(30)]
[DisplayName("家庭电话")]
public string HomeTel { get; set; }
[MaxLength(30)]
[DisplayName("手机号码")]
public string MobileNum { get; set; }
[MaxLength(10)]
[DisplayName("邮政编码")]
public string ZipCode { get; set; }
[MaxLength(40)]
[DisplayName("邮箱")]
public string Email { get; set; }
public virtual ICollection<EventSignModel> EventSignModels { get; set; }
public virtual ICollection<HealthSignMain> HealthSignMains { get; set; }
}
}
...全文
相关推荐
ASP.NET MVC5网站开发之用户资料的修改和删除3(七)
这次主要实现管理后台界面用户资料的修改和删除,修改用户资料和角色是经常用到的功能,但删除用户的情况比较少,为了功能的完整性还是坐上了。主要用到两个action “Modify”和“Delete”。 一、用户资料修改(Modify) 此功能分两个部分: public ActionResult Modify(int id) 用于显示用户信息 [httppost] public ActionResult Modify(FormCollection form)用户就收前台传来的信息并修改 1、显示用户信息 /// /// 修改用户信息 /// /
ASP.NET MVC5网站开发用户修改资料和密码(六)
主要介绍了ASP.NET MVC5网站开发用户修改资料和密码,本文即将结束member区域的用户部分,感兴趣的小伙伴们可以参考一下
JSP+Servlet+MySQL 数据库增删改查
JSP+Servlet+MySQL 数据库增删改查,适合与初学JSP,Servlet的人
Blog.rar_blog_java增删改查_个人博客系统_博客_增删改查java
个人博客系统系统,实现了增删改查,使用mysql数据库技术~~
jsp+servlet+mysql用户信息管理基础
javaweb基础课程小demo,实现了用户的增删改查功能,里面有mysql5和8的jar包,根据自己版本进行导入,压缩包里有相关图片、文本指导你进行导入项目与jar


