Presentation is loading. Please wait.

Presentation is loading. Please wait.

Customizing Views Views Customize කර ගැනීම

Similar presentations


Presentation on theme: "Customizing Views Views Customize කර ගැනීම"— Presentation transcript:

1 Customizing Views Views Customize කර ගැනීම
Module 5 Omal Perera | @omalperera Microsoft Virtual Academy

2 Views වල පෙනීම වෙනස් කර ගැනීම
Views සහ Models Razor Syntax HtmlHelper Layouts

3 Views Module 5 Microsoft Virtual Academy

4 Views වැඩ කරන විධිය Subfolders
Views folder එක තුල සිළුම views සොයාගන්න පුළුවන් Subfolders Controller එකේ නම Shared

5 View Resolution in Action
public class AlbumController : Controller { public ActionResult Index() { return View(); } } Album folder එකේ Index කියල View එකක් තියෙනවද බලන්න. Shared folder එක ඇතුලේ Index කියල View එකක් තියෙනවද බලන්න. Error

6 නැවතත් View Resolution in Action
public class AlbumController : Controller { public ActionResult Index() { return View("Default"); } } Album folder එකේ Default කියල View එකක් තියෙනවද බලන්න. Shared folder එක ඇතුලේ Default කියල View එකක් තියෙනවද බලන්න. Error

7 View Resolution

8 Views සහ Models Module 5 Microsoft Virtual Academy

9 Views සහ Models Advanced note සෑම View එකකටම Model property ඇත
@model declaration එකෙන් Type එක සෙට් කරන්න පුළුවන් Capital... Simple වෙනස හොදින් බලන්න. Advanced note Views සදහා typed model එකක් තිබීම අත්‍යවශ්‍ය නොවේ. Dyanamic views create කිරීමට උපකාරී වෙයි.

10 Razor Syntax Module 5 Microsoft Virtual Academy

11 Razor Syntax @ symbol එකෙන් server-side codes පෙන්නුම් කරයි
Context එක මත පදනම් කරගෙන MVC runtime එකේදී තේරුම් ගනී. <a generates appropriate HTML Use

12 Razor Syntax

13 HtmlHelper Module 5 Microsoft Virtual Academy

14 HtmlHelper HTML generate කිරීමට උදව් කරයි. Attributes on model
Display names Formatting Input elements

15 HtmlHelper සහ Lambdas @Html.DisplayFor(model => model.Name) MVC reflection භාවිතා කරයි Helper methods සදහා property අත්‍යවශ්‍ය වෙයි, නමුත් value එක එසේ නොවේ. @Html.DisplayFor(Model.Name) Name එක pass කරයි => m.Name) for easier reading

16 Data Dispaly කිරීම DisplayNameFor DisplayFor DisplayName attribute
Display attribute, Name property DisplayFor DisplayFormat use කරයි. (if applicable)

17 Displaying Data

18 Accepting Input LabelFor EditorFor Useful for touch
label element එකක් create කරයි Useful for touch EditorFor Input element එකක් create කරයි DataType attribute මත පදනම් කරගෙන HTML5 use කරයි

19 Basic Forms

20 Validation ValidationMessageFor ValidationSummary
Text box එක ලගින් error message එක display කරයි ValidationSummary එක තැනකදී ඔක්කොම error messages display කරයි

21 Adding Validation

22 Layouts Module 5 Microsoft Virtual Academy

23 Organization සහ Consistency
page structure එක නිර්මාණය කරගැනීමට layouts පාවිච්චි කරයි. Layout methods RenderBody() Renders anything in a view not in a section RenderSection(name, required) Allow views to add specific sections Scripts Banners Sidebars name to create section in view Note the casing

24 Using Layouts

25


Download ppt "Customizing Views Views Customize කර ගැනීම"

Similar presentations


Ads by Google