注釋和驗證:在model中使用system.componentmodel.dataannotations中包含的特性,為客戶端資料制定一些資訊,或用來驗證資料。
[required,stringlength(50)] [displayname("price"),displayformat(dataformatstring"")] [datatype(datatype.date)] 等。
使用modelstate.isvalid來驗證模型的狀態。
html helper :@using(html.beginform)
@html.display("name")返回引數 特性:@html.textbox("idname","value",new )
強化型別的htmlhelper @html.displaynamefor(m=>m.text);等。
自定義:@helper displayday(datetime day)@string.format("",day)}
控制器:使用outputcacheattribute來定義結果的快取,使用基類filterattribute時只允許在呼叫動作方法前過濾它們。
public static class myhtmlhelper
跨域請求
在 web.config==>system.webservice中新增
"access-control-allow-origin"
value=
"*"/> "access-control-allow-headers"
value=
"*"/> "access-control-allow-methods"
value=
"get, post, put, delete"
/>
C 學習之路(二)
如果處於某種原因,要將一條語句放到兩行中,可以在第一行末尾新增反斜槓 否則會出錯。左值通常是記憶體單元,右值可以使記憶體單元的內容。因此所有的左值都可用作右值,但並非所有的右值都可用作左值。例如365 year 不合理 邏輯運算符合按位運算的差別在於,按位運算子返回的並不是布林值,而是對運算元對應位...
MVC學習之路筆記(一)
linq表示式返回值的型別是iqueryable linq to ef 查詢是在資料庫端進行過濾 var temp from u in dbcontext.hksj users where u.id 4 select u 記憶體過濾 資料庫中的所有資料都查詢導程式裡面之後,進行過濾 list集合與i...
MVC學習二 Controller和View關係
控制器 controller 主要是定義方法和載入檢視 view 1.控制器中的action方法返回值的型別actionresult,string 2.控制器中action方法接收瀏覽器引數方式 2.1.通過 url路由中配置的同名引數 url stu del 1 public actionresu...