MVC--Model View Controller模型-视图-控制器,典型的设计架构,将业务逻辑、数据、界面显示分类的设计方法,采用映射技术,将业务逻辑与用户界面分离开来,达到解耦的目的,达到用户界面的重用的目的。
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // 路由名称
"{controller}/{action}/{id}", // 带有参数的 URL
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // 参数默认值
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
// 默认情况下对 Entity Framework 使用 LocalDB
Database.DefaultConnectionFactory = new SqlConnectionFactory(@"Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
} <div>
@{
name="张三";
sex=“男”;
age=16;
}
</div> 2.字符串拼接:<div>
aa @name bb
</div> 显示结果为:aa张三bb<div>
@{
for(i=0;i<10;i++)
{
@:@i
}
}
</div> 4.htmlHelper的使用,具体的用户控件的应用//文本框
@html.textBox("UserName")
//客户端生成
<input id="UserName" Name="用户名" type="text" value="">
//文本框
@html.label("lblUserName","显示值")
//客户端生成
<label for="lblUserName">显示值</label>
3 <head> //母版页 4 <title>@ViewBag.Title</title>
<span style="white-space:pre"> </span>//css格式控制
5 <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> //js格式控制
6 <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
7 </head><body> 10 @RenderBody() 11 </body>子页调用
2 @{
3 Layout = "~/Views/Shared/_Layout.cshtml";
4 }public ActionResult LayoutDemo_01()
3 {
4 ViewBag.Title = "布局页一";
5 return View();
6 }版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/whp15369657805/article/details/47164495