Creating and Configuring Models Models create කිරීම සහ config කර ගැනීම Module 2 Omal Perera | http://www.windowsgeek.lk @omalperera Microsoft Virtual Academy
Module Overview Model එකක් කියන්නේ මොකද්ද? Model එකක් create කර ගැනීම Advanced Model Concepts Microsoft Virtual Academy
Model එකක් යනු කුමක්ද? Module 2 Microsoft Virtual Academy
What is a Model? සරලව Model එකක් කියන්නේ class එකක්
Model එකක් create කර ගැනීම Module 2 Microsoft Virtual Academy
Adding a Model 20486A 03: Developing ASP.NET MVC 4 Models (More notes on the next slide)
Model එක use කරන්නේ කවුරුන්ද? User ඔවුන් interact වෙන්නේ මොනවත් සමගද? MVC Input controls Display formatting Validation
Models සාදා ගැනීම Attributes Available Attributes “Decorate” properties Available Attributes DataTypeAttribute DisplayAttribute Validation RequiredAttribute StringLengthAttribute RegularExpressionAttribute CompareAttribute
Data Types Validation Input controls Available Data Types HTML5 CreditCard Currency EmailAddress Password Url
Adding DataType Attribute 03: Developing ASP.NET MVC 4 Models Demonstrate adding attribute & resulting HTML Adding DataType Attribute (More notes on the next slide)
Prompts Display Attribute Name Display prompt and header
DisplayFormat Uses a .NET format string {0:C} {0:0.00} {0:d-m-yy} Currency {0:0.00} Always use two decimal places .42 displays as 0.42 42 displays as 42.00 {0:d-m-yy} Single digit day & month, two digit year June 10th, 2014 displays as 10-6-14 http://msdn.microsoft.com/en- us/library/system.string.format(v=vs.110).aspx
Controlling Display 20486A 03: Developing ASP.NET MVC 4 Models Demonstrate adding attribute & resulting HTML Controlling Display (More notes on the next slide)
Adding Validation Attributes Error Message Required StringLength MinLength MaxLength RegularExpression Range Error Message {0} will use the display name "{0} must be provided"
Validation එක සිද්ධ වෙන්නේ කොහෙදීද? Server එකේදී ModelState.IsValid property Client මත දී jQuery unobtrusive validation අවශ්ය වේ
Adding Validation
Advanced Model Concepts Module 2 Microsoft Virtual Academy
Models වලින් කාර්ය පහසු කරන්නේ කෙසේද? 20486A Models වලින් කාර්ය පහසු කරන්නේ කෙසේද? 03: Developing ASP.NET MVC 4 Models Automatic UI creation Model Binding Controllers are classes Actions are methods Methods take parameters MVC will convert forms to parameters
Advanced Model Concepts Custom Validation Attributes built-in attributes ඔබට අවශ්ය ලෙස නොමැති විට Integrates with MVC View Model domain and user interface අතර වෙනස Complex data Dropdown lists Unrelated objects