控制器
public ActionResult InfoFrame()
{
List<Users> list = new List<Users>();
if (Session["UserID"] == null)//判断是否没登录
{
return RedirectToAction("LoginIndex", "Login");
}
else
{
string sql = string.Format(@"SELECT * FROM Users WHERE UserID=‘{0}‘", Session["UserID"]);
list = DB.Database.SqlQuery<Users>(sql).ToList();
}
return View(list);
}
视图部分代码
@{
//ViewBag.Title = "InfoFrame";
}
@model List<MVCWEB.Models.Users>
<html>
<head>
<link href="~/Content/css/layui.css" rel="stylesheet" />
<link href="~/Content/css/style.css" rel="stylesheet" />
<link href="~/Content/css/iconfont.css" rel="stylesheet" />
<script src="~/Scripts/jquery.js"></script>
<script src="~/Scripts/layer.js"></script>
<script src="~/Scripts/layui.js"></script>
</head>
<body>
<form class="layui-form" action="" style="margin-left:0px; margin-left:100px">
<div class="layui-form-item">
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="font-size:18px;">帐号:</label>
<div class="layui-input-block">
<input type="text" name="title" value="@Model[0].UserName" required lay-verify="required" @*placeholder="请输入帐号"*@ autocomplete="off" class="layui-input" readonly="readonly" style="width:500px;font-size:16px">
</div>