@model IEnumerable<G6.Model.UserModel>
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<p>
<a asp-action="Create">Create New</a>
</p>
<table class="table">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.UId)
</th>
<th>
@Html.DisplayNameFor(model => model.LoginName)
</th>
<th>
@Html.DisplayNameFor(model => model.LoginPwd)
</th>
<th>
@Html.DisplayNameFor(model => model.UName)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.UId)
</td>
<td>
@Html.DisplayFor(modelItem => item.LoginName)
</td>
<td>
@Html.DisplayFor(modelItem => item.LoginPwd)
</td>
<td>
@Html.DisplayFor(modelItem => item.UName)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</tbody>
</table>
</body>
</html>
ADD
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>AddUser</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<script src="~/lib/jquery/dist/jquery.js"></script>
<script>
function AddUser() {
var obj = {
LoginName: $("#txt_loginName").val(),
LoginPwd: $("#txt_loginPwd").val(),
UName: $("#txt_Name").val()
};
$.ajax({
url: "/User/AddUser",
type: "post",
dataType: "json",
data: obj ,
success: function (d) {
if (d > 0) {
alert("添加成功");
}
}
})
}
</script>
</head>
<body>
<div align="center">
<table class="table table-bordered" style="40%;">
<tr>
<td>登录名:</td>
<td><input id="txt_loginName" type="text" /></td>
</tr>
<tr>
<td>密码:</td>
<td><input id="txt_loginPwd" type="text" /></td>
</tr>
<tr>
<td>用户姓名:</td>
<td><input id="txt_Name" type="text" /></td>
</tr>
<tr>
<td colspan="2"><input id="btn_Save" type="button" class="btn btn-primary" value="提交" onclick=" AddUser();" /></td>
</tr>
</table>
</div>
</body>
</html>