• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/14

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

14 Cards in this Set

  • Front
  • Back

What happens when we do not specify which controller is to be called,

by default it will call the HomeController



so if we open our application via an URL that does not specify controller it will call HomeController. (http://localhost:54567)



Also if you do not specify which method to call it will call the Index method.

How to call the About method from a controller

http://localhost:54567/home/about



controller/method



(the actual file is named Homecontroller but we call controller)


http://localhost:37827/xyz/abc

Requirements for naming controllers?

Should start with a capital letter and contain the world controller



XyzController

What methods under controller Xyz will the following opne http://localhost:37827/xyz/

Index()



the default method

Pass an object (model) to a view

Controller


// define Model


alex.FirstName = "Alex";


alex.LastName = "Rod";


// pass Model


return View(alex);



View


@model mvce.Models.Student //very first row


// mvce name of proj



@Model.FirstName // not that Model is capital


@Model.LastName

Pass multiple object (model) to a view

Controller


// create 3


// if we want to pass multiple objects we create a list add all objects to the list and then pass that list to the view


List<Student> students = new List<Student>();


students.Add(alex);


students.Add(lynda);


students.Add(john);



// controller calls the view


// to call a particular view we need to create it. if not defined it looks for the action method Abc and based on that will look for Abc.cshtml


// return View(alex);



return View(students);


View


@model IEnumerable<mvce.Models.Student>



@foreach (var item in Model)


{


<h2>Student Name: @item.FirstName @item.LastName</h2>


}

how can we pass objects of different type to a view

create a class that serves as container

accessing items in a list

in cshtml



@foreach (var item in Model)


{


<h2>Student Name: @item.FirstName @item.LastName</h2>


}

creating a list

List<Student> students = new List<Student>();


students.Add(alex);


students.Add(lynda);


students.Add(john);

accessing a list that is part of a class

in cshtm



@foreach (var item in Model.students)


{


<h2>Student Name: @item.FirstName @item.LastName</h2>


}



//Students is a list under @model mvce.Models.Container

Where is the file that needs to be manipulated if we want to change the design of the page layout? Its name

In the project under



View > Shared



File is _Layout.cshtml

location of the css

Content folder all the CSS

Adding new css file or replacing any of the default

Folder App_Start


File BundleConfig.cs



...



bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(


"~/Content/themes/base/jquery.ui.core.css"));


..

where we specify the layout to be used

_ViewStart.cshtml



@{


Layout = "~/Views/Shared/_Layout.cshtml";


}



<!-- we can change layout -->