@{
ViewBag.Title = "Index";
Layout = null;
}
Jquery实现数据双向绑定(赋值和取值)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MVC_demo.Controllers
{
public class DefaultController : Controller
{
// GET: Default
public ActionResult Index()
{
var model = new Data()
{
id = 1,
name = "张三",
area = "futian",
sex = "male",
hobby = "music,movie",
intro = "你好,世界"
};
ViewBag.Data = model;
return View();
}
public ActionResult SavaData(Data data)
{
var result = new result();
result.success = true;
return Json(result);
}
}
///
/// 数据类
///
public class Data
{
public int id { get; set; }
public string name { get; set; }
public string area { get; set; }
public string sex { get; set; }
public string hobby { get; set; }
public string intro { get; set; }
}
///
/// 通知类
///
public class result
{
public bool success;
public string message;
}
}