Saturday, July 23, 2016
Saturday, July 9, 2016
ASP MVC
Bootstrap: js/css framework
Razor: front-end framework like struts
@Html.DropDownListFor
Code First Data Annotations:
Model->database framework
key如果自定义的话不是identity的话就要用[DatabaseGenerated(DatabaseGenerationOption.None)]
其他validation
Identity:
[DatabaseGenerated(DatabaseGenerationOption.Identity)]
需要manually加入[Id] Int Identity(1,1)
NuGet push changes to database:
Update-Database -Verbose -Force
Route:
http://www.codeproject.com/Articles/641783/Customizing-Routes-in-ASP-NET-MVC
Controller:
Delete non-required fields here

Pirce price = db.Prices.ToList().Where(row=>rowId == priceid).First();
return RedirectToAction("Select", "Manufacturers", new {id=1});
Model:
View:
@Url.Action既可用于view也可用于controller不要hardcode url尽量用这个。
@Html.ActionLink("Add another price","Select","Manufacturers", new {id=1},null);
window.location.href='@Url.Action("Create")'+'/'+'@ViewBag.id';
@using (Html.BeginForm(null,null,FormMethod.Post, new{id="myForm",@onSubmit="return validate();"}))
@Html.HiddenFor(model=>model.Id)
Publish website in Windows:
1. publish website to local(right click proj in VS2015)
2. copy all files to production iis dir
3. Restart Default web site
https://www.youtube.com/watch?v=zWFoZb6EiwU&list=PLkhqom1HfPQrtTsUzSZk2Xvs2_F-CGTDq&index=1
select2是一个很好的搜索型多选和单选插件。
datepicker也是日历选择器首选。
$('#radio').select2().val(['700','750']).trigger('change');
Razor: front-end framework like struts
@Html.DropDownListFor
Code First Data Annotations:
Model->database framework
key如果自定义的话不是identity的话就要用[DatabaseGenerated(DatabaseGenerationOption.None)]
其他validation
Identity:
[DatabaseGenerated(DatabaseGenerationOption.Identity)]
需要manually加入[Id] Int Identity(1,1)
NuGet push changes to database:
Update-Database -Verbose -Force
Route:
http://www.codeproject.com/Articles/641783/Customizing-Routes-in-ASP-NET-MVC
Controller:
Delete non-required fields here
Pirce price = db.Prices.ToList().Where(row=>rowId == priceid).First();
return RedirectToAction("Select", "Manufacturers", new {id=1});
Model:
Add caption |
View:
@Url.Action既可用于view也可用于controller不要hardcode url尽量用这个。
@Html.ActionLink("Add another price","Select","Manufacturers", new {id=1},null);
window.location.href='@Url.Action("Create")'+'/'+'@ViewBag.id';
@using (Html.BeginForm(null,null,FormMethod.Post, new{id="myForm",@onSubmit="return validate();"}))
@Html.HiddenFor(model=>model.Id)
Publish website in Windows:
1. publish website to local(right click proj in VS2015)
2. copy all files to production iis dir
3. Restart Default web site
https://www.youtube.com/watch?v=zWFoZb6EiwU&list=PLkhqom1HfPQrtTsUzSZk2Xvs2_F-CGTDq&index=1
select2是一个很好的搜索型多选和单选插件。
datepicker也是日历选择器首选。
$('#radio').select2().val(['700','750']).trigger('change');
Subscribe to:
Posts (Atom)