SlideShare a Scribd company logo
1 of 16
ASP.NET MVC4
JASON
 當填寫會員表單時,輸入帳號後,並檢查帳號是否已

存在?
 搭配 Jquery Validate
 「Remote」Attribute
 Constructors
 使用「Remote」Attribute
 Model:
 Implement an action method to support your

Remote attribute
 Result:
 假設有個 Model,現在想要把全部欄位都加上

[Required],然後每新增一個Property也加上
[Required],除了手動加上去外,還有其他辦法嗎?
 Inherit DataAnnotationsModelMetadataProvider


Implements the default model metadata provider for ASP.NET
MVC.



Override 「 CreateMetadata 」Method.
MetadataProvider
ModelMetaData
 How use?
 某表單輸入後按下 submit 後,在 controller 修改了

model 的值,return view 後,網頁上的 textbox 的值
卻不會改變?

submit
 Solution:
 Add ModelState.Clear();
 Q&A

More Related Content

More from LearningTech

More from LearningTech (20)

Docker
DockerDocker
Docker
 
Semantic ui
Semantic uiSemantic ui
Semantic ui
 
node.js errors
node.js errorsnode.js errors
node.js errors
 
Process control nodejs
Process control nodejsProcess control nodejs
Process control nodejs
 
Expression tree
Expression treeExpression tree
Expression tree
 
SQL 效能調校
SQL 效能調校SQL 效能調校
SQL 效能調校
 
flexbox report
flexbox reportflexbox report
flexbox report
 
Vic weekly learning_20160504
Vic weekly learning_20160504Vic weekly learning_20160504
Vic weekly learning_20160504
 
Reflection & activator
Reflection & activatorReflection & activator
Reflection & activator
 
Peggy markdown
Peggy markdownPeggy markdown
Peggy markdown
 
Node child process
Node child processNode child process
Node child process
 
20160415ken.lee
20160415ken.lee20160415ken.lee
20160415ken.lee
 
Peggy elasticsearch應用
Peggy elasticsearch應用Peggy elasticsearch應用
Peggy elasticsearch應用
 
Expression tree
Expression treeExpression tree
Expression tree
 
Vic weekly learning_20160325
Vic weekly learning_20160325Vic weekly learning_20160325
Vic weekly learning_20160325
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
git command
git commandgit command
git command
 
Asp.net MVC DI
Asp.net MVC DIAsp.net MVC DI
Asp.net MVC DI
 
Vic weekly learning_20151127
Vic weekly learning_20151127Vic weekly learning_20151127
Vic weekly learning_20151127
 
Mocha.js
Mocha.jsMocha.js
Mocha.js