Skip to content

ASPNET Core 5 MVC Bootstrap Responsive Web Programming Lecture 5 Layout ViewStart Import

FurkanGozukara edited this page Nov 16, 2026 · 1 revision

ASP.NET Core 5 - MVC - Bootstrap - Responsive Web Programming - Lecture 5: Layout, ViewStart, Import

ASP.NET Core 5 - MVC - Bootstrap - Responsive Web Programming - Lecture 5: Layout, ViewStart, Import

image Hits Patreon BuyMeACoffee Furkan Gözükara Medium Codio Furkan Gözükara Medium

YouTube Channel Furkan Gözükara LinkedIn Udemy Twitter Follow Furkan Gözükara

#SoftwareDevelopment #Software #Engineering #CSharp #Coding #Course

Asp.NET Core V5 - MVC Pattern - Bootstrap V5 - Responsive Web #Programming with C# Full Course Playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsnAWtgk4ja3HN3xgMKF7BOE

GitHub repository of the course : https://github.com/FurkanGozukara/Responsive-Web-Design-With-ASP.NET-5-and-MVC-Pattern-and-BootStrap-5-2021

Discord channel link of the course : https://discord.gg/6Mrb8MwteQ

How to use Discord : https://youtu.be/AEwPtYiLvsQ

In Lecture 5:

  • What is a layout in a web design

  • How to design layouts in ASP.NET Core MVC projects

  • How the hierarchical levels/availability of layouts in ASP.NET MVC

  • What are the default paths of views, layouts, etc. in ASP.NET MVC

  • What is ViewStart in ASP.NET MVC Core

  • How to use ViewStart and how to define different ViewStarts for different Views

  • What are the sections in layouts of ASP.NET MVC

  • How to define and use sections in ASP.NET MVC Views

  • How to make a section optional

  • What is ViewImport in ASP.NET MVC Core

  • How to use ViewImport and how to define different ViewImports for different Views

  • How to globally include scripts or libraries into Views by using ViewStarts or ViewImports

last page : https://asp.mvc-tutorial.com/layout/introduction/

Please subscribe and make comments.

This course requires fundamental knowledge about programming and C#. So please watch our below playlists related to C#.

Our courses playlists are like below:

[1] Introduction to Programming Full Course with C# playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffskoSXySh0MdiayPJsBZ7m2o

[2] Advanced #Programming with C# Full Course Playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslHaBdS3RUW26RKzSjkl8m4

[3] Object Oriented Programming Full Course with C# playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsnH3XJb66FDIHh1yHwWC26I

[4] Asp.NET Core V5 - MVC Pattern - Bootstrap V5 - Responsive Web #Programming with C# Full Course Playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsnAWtgk4ja3HN3xgMKF7BOE

[5] Artificial Intelligence (AI) and Machine Learning (ML) Full Course with C# Examples playlist: https://www.youtube.com/playlist?list=PL_pbwdIyffskVschrADCL6KEnL_nqDtgD

[6] Software Engineering Full Course playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslgxMVyXhnHiSn_EWTvx1G-

[7] Security of Information Systems Full Course playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslM_o92NwkaUzD7C6Fekx26

[8] (Turkish) Bilgisayar Becerileri Tam Ders playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsmyE2e909ea1MXLcMb8MenG

auto subtitle timing : NA

Video Transcription

  • 00:00:02 Hello dear students. Welcome to the lecture 5 of responsive web design with asp.net 5

  • 00:00:06 and MVC pattern and bootstrap 5, so if you remember that we have seen partial believes

  • 00:00:15 the previous week and so we will continue from our next chapter today and to do that.

  • 00:00:24 I will just copy and paste the previous week's source code.

  • 00:00:30 By the way, some of our students set me that could be do it from beginning even though

  • 00:00:40 I am copy and pasting the previous lectures quote. We have reading everything from scratch.

  • 00:00:48 So if you start from lecture 1 you will see all the coding up to the lecture 5.

  • 00:00:56 if you have specific questions, feel free to ask me them in our Discord Channel and

  • 00:01:02 if you still cannot understand that then you can

  • 00:01:11 try to re watch our previous lectures.

  • 00:01:21 Okay.

  • 00:01:27 Okay, so

  • 00:01:32 Today we are going to start with layout of our websites projects. Let's start with introduction.

  • 00:01:45 Ever since the first website was created and expanded from a single page to several Pages

  • 00:01:50 the need to share specific parts of the pages became obvious use cases for this ranges from

  • 00:01:56 having the same footer at the bottom of each page belonging to the same website to reusing

  • 00:02:01 very complex layouts metadata and everything else around the actual content of a webpage

  • 00:02:07 for example on this page right now. We are seeing a lot of we use the such as this menu

  • 00:02:13 bar or

  • 00:02:14 Is download the PDF part or the footer here's and even this layout at the right side is

  • 00:02:23 same but it changes according to our current page, but it is repeating and okay, our project

  • 00:02:35 is opened. So I will just start with renaming to solution name.

  • 00:02:42 This doesn't rename our namespace therefore not everything is renamed but it is still

  • 00:02:50 better than nothing and each lecture source code is being available on our GitHub repository.

  • 00:03:01 And one more thing I want to mention is.

  • 00:03:05 Okay, let me check it.

  • 00:03:13 Okay, we have also seen with company's previous week and they were even better than the partial

  • 00:03:22 waves. But according to your needs you can use either partial views or Viv components

  • 00:03:29 both is fine.

  • 00:03:31 Okay, let's continue with the layouts.

  • 00:03:39 Various server-side technologies have solved this problem in different ways from the include

  • 00:03:44 statement of PHP to the master Pages technology of asp.net web forms. They all come with their

  • 00:03:51 own set of advantages and disadvantages, but they all solve the same problem. They allow

  • 00:03:56 you to reuse all this stuff that would otherwise have to be repeated in each file and even

  • 00:04:01 worse manually edited in each file for even the smallest Global change and only specified

  • 00:04:07 the unique content for each

  • 00:04:08 Your pages? Okay, so this is actually

  • 00:04:11 A methodology that you have to follow in your entire program carriers. What I mean is you

  • 00:04:22 should never do copy paste of code. You should never have duplicate code in your projects.

  • 00:04:28 You have to make them like a class or method or another thing to reuse them. Okay Library

  • 00:04:37 dll file with this way the changes you made is

  • 00:04:45 Apply to every where you don't have to manually change it from wherever you have copy and

  • 00:04:51 pasted it makes your code more efficient easier to understand easier to manage many more things.

  • 00:04:59 So never have copy pasted code never have duplicate code. Okay. This is a mandatory

  • 00:05:08 rule for programming.

  • 00:05:14 In asp.net MVC you can use something called a layout often in combination with sections.

  • 00:05:21 You can have one or several layouts in your project and each can include zero or more

  • 00:05:25 sections. We will go through all the various layout related Concepts in the following articles.

  • 00:05:31 Okay, so that our layout and layouts have sections. So this is what we are going to

  • 00:05:38 see. Okay layout files.

  • 00:05:42 As discussed in the introduction to this chapter a layout file allows you to reuse common mark

  • 00:05:47 up across multiple web pages in your project. This is done by specifying all the common

  • 00:05:53 stuff in a layout file and then referencing this file in all of your subpages unless you

  • 00:05:58 don't want them to use the common layout, of course.

  • 00:06:02 So if you are adding a page that will use your common layout that you include your layout

  • 00:06:08 file. For example, each page of this website includes a common layout which is many of

  • 00:06:15 our the right sidebar the photos and such it is the same in many of the websites. It

  • 00:06:22 is same in many of the websites that you already use. If you if you pay attention you will

  • 00:06:29 notice that

  • 00:06:34 In asp.net MVC layout files looks just like a regular View and they also use the same

  • 00:06:39 extension CSS HTML. It could look like this. Okay. So this is a nail file. So what do we

  • 00:06:48 see different in this layout file? We see that a special method call render body. Okay.

  • 00:06:54 So this is something new to us.

  • 00:07:00 Notice how it's almost just a regular HTML file except for the render body razor method.

  • 00:07:07 This part is required in a layout file because it specifies where the content of the page

  • 00:07:12 using the layout should be placed the file using the layout could look like this. So

  • 00:07:17 this is a layout CSS HTML they are test. So this is a regular page which includes a layout

  • 00:07:24 it is coming from we've shaded layout CSS HTML as you can see, so this is the naming

  • 00:07:30 And it has helloworld.

  • 00:07:33 Again, the magic happens in the razor part where we specify the layout to be used asp.net

  • 00:07:42 MVC will now combine these two files each time. The layout test view is used resulting

  • 00:07:47 in something like this when the page is returned to the browser.

  • 00:07:51 Okay, I will just do an example in a moment.

  • 00:07:57 Adding a layout to your MVC project.

  • 00:08:01 We already discussed in a previous article how you can add views to your project fortunately.

  • 00:08:07 It's just as easy to add a layout view to your project as I will now demonstrate but

  • 00:08:12 there are a couple of guidelines that I would like for you to know about first. Okay guidelines

  • 00:08:16 are important part of NBC programming layouts are usually placed in a subfolder of the views

  • 00:08:24 folder called shared. This is one of the places asp.net will automatically search if you don't

  • 00:08:29 specify a

  • 00:08:30 a full path to your layout file. Okay. This is this also have has been asked to me that

  • 00:08:37 how Microsoft finds pets it looks for default pets for layouts. It looks very useful ders

  • 00:08:46 then shaded folder. Okay. If you don't put your layout file inside your shaded folded,

  • 00:08:52 then you have to specify full path such as here. This is the full path as you can see

  • 00:08:59 it uses these servers.

  • 00:09:01 It's route special character. This means that go to the root of the server. Okay?

  • 00:09:14 The filename of layout views are usually prefixed with an underscore to indicate that this is

  • 00:09:19 not a regular view. If you only plan on using one layout, it could be called simply underscore

  • 00:09:25 layout CSS HTML. Otherwise use a name to indicate what the layout will be used for EG underscore

  • 00:09:33 authenticated user layout CSS HTML. Okay. This makes so much sense because usually you

  • 00:09:40 display two different layouts to your users first.

  • 00:09:44 Is when the user is logged in and the second one is when the user is not logged in. So

  • 00:09:52 basically you can have two different layouts. I it can be also achieved with using single

  • 00:09:59 layout as well. But it is totally up to you how you design it so you can have multiple

  • 00:10:03 layouts or have single layout.

  • 00:10:08 With that in mind, let's add a layout to our project. I'm assuming that you already have

  • 00:10:13 a views folder with a shared folder inside. If not, you may add it as described previously

  • 00:10:19 in this tutorial. Okay. So let's add a layout into our shaded folder here. I'm going to

  • 00:10:28 add with

  • 00:10:30 Okay so bad. I'm too babe.

  • 00:10:38 Dan I will name it as

  • 00:10:45 Masters layout okay

  • 00:10:46 UCI we have removed extension, but it will be automatically added. So this is the razor

  • 00:10:56 give page. There is also lay razor layout as well. But you see it is actually same let's

  • 00:11:04 use Master layout CSS. HTML is reason lay off.

  • 00:11:10 Okay. So this is the layout page you see it has the simple HTML information meta name

  • 00:11:21 and content device, which you see it uses Visual Basic title. So this title will come

  • 00:11:30 from the VF page that inherits this layout. Okay, and the body here will come from the

  • 00:11:39 page.

  • 00:11:40 It inherits this layout. Okay, so we will see that how it works. We have now our layout

  • 00:11:47 as Master layout.

  • 00:11:51 The file called underscore layout CSS HTML will now be created consisting of basic HTML

  • 00:12:01 in an empty layout statement in the top. All you need to do is add your own markup. And

  • 00:12:06 then remember to add a call to the render body method in the place where you want the

  • 00:12:10 page content to be inserted like this. Okay. So now as we can see they are automatically

  • 00:12:18 added here vendor body and it doesn't have any

  • 00:12:23 Layout reference and it has the big title. Okay now we can reference it in our

  • 00:12:33 Pages. Okay. So let's a test.

  • 00:12:41 So let's make some.

  • 00:12:45 Rehearsal of our previous lectures first, I will start with a new controller.

  • 00:12:51 So let's call this controller is lecture 5.

  • 00:12:58 Okay.

  • 00:13:00 lecture 5 okay lecture 5 controllers

  • 00:13:06 And for this controller, I am going to add lecture 5, so I will use the naming convention.

  • 00:13:14 I will add a new folders lecture 5

  • 00:13:18 And inside lecture 5. I will add a new VF by default. It is index view as you know,

  • 00:13:26 so let's add a razor. We've okay. So you see we can when we select a VF we can also pick

  • 00:13:35 our templates and you see reference equipped libraries and use a layout page. We can also

  • 00:13:42 include a layout page.

  • 00:13:45 Okay, I will not use a layout page here. I am just adding a simple gift.

  • 00:13:56 Since we have selected include scripts, I think it's taking a bit longer time.

  • 00:14:05 So the lecture five controller is ready here lecture 5 we have is getting edit. You see

  • 00:14:12 still we are using lecture one name space because we are doing copy and paste. Okay,

  • 00:14:19 so it has failed show. Let's just add a laser beam empty. We don't need anything includes

  • 00:14:25 right now. Okay index.html. I can give any name to this.

  • 00:14:31 It is totally up to me. So let's use the default name conversion. Okay, so are empty we is

  • 00:14:41 ready and let's add a model.

  • 00:14:47 To use in these near me. Okay, I can use the existing models as well. But it's kind of

  • 00:14:53 We Are.

  • 00:14:57 Seeing again our previous lecture. So let's call this model name. What can it be e-commerce.

  • 00:15:05 Let's make it e-commerce or perhaps something else. Okay School management.

  • 00:15:14 our school library

  • 00:15:17 Okay, I will name it as cold night library. It's a regular class actually.

  • 00:15:27 Okay. So in this school library, what do we have? What should we have? Let's have

  • 00:15:33 a manager named for example, okay, let's make it as string and

  • 00:15:45 When is your name and let's have list of books?

  • 00:15:53 I am currently designing a simple.

  • 00:15:58 Model so let's make it a okay name of books. Okay.

  • 00:16:08 All right. Let's make it like this. Okay. So let's go back to our lecture 5 current

  • 00:16:18 the our lecture 5 in day says nothing. It's controller is

  • 00:16:24 Yes, so when we call lecture 5 is for the return view which we have it will return in

  • 00:16:33 this view under lecture 5 here index.html. So let's set it to our starting page. How

  • 00:16:43 do we do it?

  • 00:16:46 We do it under startup and the default will be controller as lecture 5 action will be

  • 00:16:56 index.

  • 00:16:57 And it can take ID to our index takes any ID here our index action.

  • 00:17:03 No, it doesn't take anything. So providing it doesn't make any difference and let's write

  • 00:17:13 it here. Hello world lecture.

  • 00:17:19 Five index. Okay. Let's run our application to see.

  • 00:17:36 So this will be our default searching page because we have said it in our startup. We

  • 00:17:42 will see more about routing and we haven't come to that part yet. So don't worry about

  • 00:17:51 it at the moment.

  • 00:17:54 Okay, you see Hello World lecture 5 index is running. So actually this is equal to make

  • 00:18:02 sure 5.

  • 00:18:06 Index you see it's the same.

  • 00:18:11 Okay. So let's add another's Vivan the lecture 5.

  • 00:18:18 MTV so let's name it as list Books Okay. This will be empty list books. Okay. So, how can

  • 00:18:32 I call this page right now?

  • 00:18:36 How can I call first I will show you the incorrect way list of books page in of lectures by currently.

  • 00:18:51 Can I visit this page somehow?

  • 00:18:54 With full pads, I think I can but with the traditional way, let's see. Okay. So this

  • 00:19:05 was equal to lecture 5 index. Can I access it with list of books?

  • 00:19:13 No, so it is under views folder this.

  • 00:19:20 The nature v. No still fading

  • 00:19:23 Okay, so how can I access this list of books a list books? Sorry about that.

  • 00:19:35 Okay still not working.

  • 00:19:38 Okay, so I am not able to access this because in nvram is separating the model view and

  • 00:19:48 controller to so this is a view page to access this view page. I am going to add an action

  • 00:19:55 to lecture 5.

  • 00:19:58 Okay.

  • 00:20:00 So I will name the action as whatever the name you want list books. Okay, and this will

  • 00:20:08 return we have but which we've RV name is same as list book. So if I return we have

  • 00:20:16 it will return a list books. We've okay. So if I give another name to this books just

  • 00:20:24 then I have to provide differently.

  • 00:20:27 Okay, so I will do several 8-bit example, so you will understand this. So now with list

  • 00:20:36 books action now it should work.

  • 00:20:40 Because we are following the default naming convention. I am showing this because some

  • 00:20:46 of our students has messaged me and set me that they are having hard time to understand

  • 00:20:54 so lecture 5 is books. So this is the action name. Okay. You see now it is working now.

  • 00:21:04 I will add another one.

  • 00:21:09 So let's name This Is Us.

  • 00:21:12 Another view by Will name it as iteration is something really different.

  • 00:21:20 iteration

  • 00:21:22 and iterating books on this page. Okay, and I will access this.

  • 00:21:36 Here with a different action name. Okay, I will access this give it just lists action.

  • 00:21:43 So now I have to provide the name of the video because they are not matching. Okay this matching

  • 00:21:50 weaves. Okay, then lecture 5 then list books Chase HTML. Therefore I can call it exactly

  • 00:22:01 as it is this

  • 00:22:03 does not matching

  • 00:22:06 we use K lectures 5

  • 00:22:13 and list says HTML therefore provides view name. Okay. I will just provide the vivre

  • 00:22:24 name of iteration.

  • 00:22:26 I wonder if we need to write extension or not. Let's try.

  • 00:22:38 However, we are still not providing the full patch. Okay, if you want to prove why because

  • 00:22:46 still following the default naming convention. Therefore. We don't need to provide full pads

  • 00:22:53 yet so lecture 5

  • 00:22:57 List, okay. It is working. So we don't provide CSS HTML then I will add another.

  • 00:23:07 action here

  • 00:23:09 test

  • 00:23:12 Okay, and this time I want to call unconventional test. Okay, so it will be like this.

  • 00:23:27 on conventional

  • 00:23:30 Okay.

  • 00:23:33 Test done this time. I have to write full path. This will call another Viv.

  • 00:23:43 Old Pat. Okay. So now I am expecting to see test CSS HTML.

  • 00:23:55 We haven't seen the layout yet about I will show you that don't worry. So we are remembering

  • 00:24:06 our information because and we see is rather hard to understand. Okay, so to call it then

  • 00:24:16 now I will call lecture five tests now. It is working as expected. Okay, so now let's

  • 00:24:23 add our

  • 00:24:29 Master layout to our

  • 00:24:34 Index. So, how do we do that?

  • 00:24:38 To do it. We referenced layout. So the layout will be equal to I wonder if he can just provide

  • 00:24:47 the name because we are using the default convention.

  • 00:24:57 Okay, let's just first try with it.

  • 00:25:07 Just the name of the layout because you are using the default path.

  • 00:25:19 Okay, so it appears that our layout has hey, we can't know that our layout valid or not.

  • 00:25:35 So let's just add a style here. Okay. I will make the background colors.

  • 00:25:42 Let's make it that unless this sort.

  • 00:25:48 Since we don't have title or we don't have any styling in our layout to be able to see

  • 00:25:58 whether our layout is working or not. Let's just add some. Okay, so our layout is working.

  • 00:26:06 you see this is working because okay layout is

  • 00:26:13 Place it on the Reeves shaded with CSS HTML extension. Okay, so so I didn't have to

  • 00:26:28 therefore I didn't have to provide full Pat. How was the full path? The full path sub was

  • 00:26:38 like this.

  • 00:26:40 Okay, okay.

  • 00:26:43 All right. So all layouts now works so we can do anything we want with the layout and

  • 00:26:52 then it will be applied on every page that includes the layout.

  • 00:26:59 So such as let me show you.

  • 00:27:06 Let's get the layers. So this is the render body and after the render body, let's put

  • 00:27:12 another div here and that's right the title right of the page is you back.

  • 00:27:22 Title currently we didn't set any title. Okay, so I will set the title here. How am I going

  • 00:27:38 to do that?

  • 00:27:40 Okay, title equal to the index page or let's say lecture 5.

  • 00:27:50 Okay, we can set it like this I think to be able to set it if you need to open and close

  • 00:27:59 some.

  • 00:28:00 Server-side code. Okay. So this is just a signing parameter to be paid with back, but

  • 00:28:11 we can do it on here as well. So let I will just keep it here.

  • 00:28:20 And on our controllers. Okay, let's add iteration. They are as well.

  • 00:28:27 here

  • 00:28:28 It's a nation. Let's enter a odds.

  • 00:28:35 Okay, only iteration page.

  • 00:28:38 Which we call from our here I will set a Titan.

  • 00:28:47 Equal to this is iteration page title.

  • 00:28:55 Set in controller.

  • 00:28:59 And for list of books list books, I won't have any title. So let's get list books as

  • 00:29:07 well.

  • 00:29:08 Okay, here's okay. So, let's see each page and how they are.

  • 00:29:18 Print it on the secret.

  • 00:29:22 Okay. So the first one is r

  • 00:29:34 Index page, okay title of the page is index page of the actual pipe. It is working as

  • 00:29:38 expected. Then let's see lecture 5 and 4 iteration. What was our action name?

  • 00:29:49 Okay, it was list, so let's call the list action.

  • 00:29:56 Okay, it is still working. Now. We have set this in controller and finally list book.

  • 00:30:03 Only Spooks was - okay. This books.

  • 00:30:09 It is not.

  • 00:30:12 Uppercase or lowercase sensitive as you can see it's case-insensitive. Okay, title of

  • 00:30:20 the page is empty. So the name work is handling null values, obviously, so this is a null

  • 00:30:31 value. But if it is, no, it doesn't throw any error. It is just printing an empty string

  • 00:30:39 or nothing.

  • 00:30:41 Okay, so now we can continue. I am hoping that this has refreshed your memory of our

  • 00:30:51 previous lectures.

  • 00:30:53 Okay, so next.

  • 00:30:58 Okay.

  • 00:31:02 Okay, so let's continue with the weave start file.

  • 00:31:12 In the previous article, we learned how to define create a layout view which could be

  • 00:31:16 reused across multiple views. The layout is applied to a view whenever it's referenced

  • 00:31:21 through the layout property like this. Yes. We have seen that.

  • 00:31:28 Under normal circumstances, you would have to do this for all the pages where you want

  • 00:31:32 to use this layout. That's pretty cool because it gives you the flexibility to use multiple

  • 00:31:37 layouts or even have Pages which doesn't use a shared layout however for a lot of projects

  • 00:31:43 you will likely have only one common layout or at least one you use in most situations

  • 00:31:49 fortunately for us. There's an easy way to specify a default layout which will be used

  • 00:31:54 unless you specifically override it within the page The View start.

  • 00:31:58 L okay, so instead of adding manually to each page that we have we can use default layout

  • 00:32:07 and we will override it in we've start file. So what is beef start file?

  • 00:32:17 The view start file is actually much like a normal View and it also has the same extension

  • 00:32:21 CSS HTML. So to use it you should just Add A View to your views folder called underscore

  • 00:32:27 view start CSS HTML. We'll get to that in a minute. But for now you should know that

  • 00:32:34 asp.net MVC will automatically look for a view start file and interpret it before it

  • 00:32:39 interprets the actual page view that allows you to specify common functionality like in

  • 00:32:45 this case where we

  • 00:32:46 Use it to specify a default layout for all pages, but first let's add a view start file

  • 00:32:53 to our project. Okay. So this is really important to understand. Let's repeat this part asp.net

  • 00:33:02 MVC will automatically look for a view start file and interpret it before it interprets

  • 00:33:07 the actual page view that allows you to specify common functionality so we can use with start

  • 00:33:14 to Define common functionality.

  • 00:33:16 T which would be included all of our we views therefore we can make any modification which

  • 00:33:25 would be reflected to all of all of our view pages. So it is a great thing to use actually

  • 00:33:32 like we can Define include JavaScript libraries or other things in diff start and they will

  • 00:33:40 all available in our in all our View files.

  • 00:33:48 Just like for layout files the file name should be prefixed with an underscore to state that

  • 00:33:53 this is not just a regular view. Okay?

  • 00:34:00 The content of this file should be just what you need to do before a regular view as interpreted.

  • 00:34:05 There are many use cases for this but the one will look into as defining a default fall

  • 00:34:10 back layout which will always be used unless specifically overridden it can be done like

  • 00:34:15 this. Okay. So basically the is that the time we see is looking we've start series HTML

  • 00:34:23 which is placed under we use let's do it.

  • 00:34:34 What's an active?

  • 00:34:39 Just lame name it as we've start. Yes. It is here. And in this video, we'll start we

  • 00:34:47 will Define the layout. Okay. So this was our layout

  • 00:34:55 Okay, now layout will be included in all pages version. There is no layout set it. So for

  • 00:35:07 example, we didn't set layout in our previous Pages for example product index. Let's see

  • 00:35:15 it.

  • 00:35:19 Okay.

  • 00:35:23 Now whenever you add a view to your project, you can check that use a layout page option

  • 00:35:28 as seen on the screen shot, but leave the text field empty your layout will automatically

  • 00:35:33 be applied to your new view and you don't have to set the layout property manually for

  • 00:35:38 each view anymore. Okay. Let's see. It's for example product Dynamic. Okay, as you can

  • 00:35:45 see our layout is now available.

  • 00:35:52 So the python is here. So the we've start is already working. Can we override the layout

  • 00:36:01 provided in GIF start Let's test that as well. So I will add another layout here under the

  • 00:36:13 Shaded. Let's say new item.

  • 00:36:16 These will be empty. I will name it as layout seconds.

  • 00:36:25 Okay, so inside this layouts.

  • 00:36:29 I will copy and paste this and this time let's use a different color. For example.

  • 00:36:40 wrong, okay, and let's apply a layout second to our

  • 00:36:51 let's see.

  • 00:36:56 Index page of lecture 5 so second layout so this should override the layout provided in

  • 00:37:07 with start.

  • 00:37:23 Since these are defined server-side controls. Okay, so it says there is no second layout

  • 00:37:32 we have provide different name.

  • 00:37:37 A layout second. Yes.

  • 00:37:41 Okay error also displaying which paths it has looked so it has looked buse lecture 5

  • 00:37:47 Second layout we've shared second layout Pages share the second layer. So the Microsoft asp.net

  • 00:37:55 core. I'm Missy has looked to these three places and all of them have faded. Therefore.

  • 00:38:03 It has thrown an error.

  • 00:38:08 Spark

  • 00:38:11 if I don't Define any layout, then it will use the layout that we have defined it in

  • 00:38:17 the Viv start file. Here's okay. So it is working now we can look for example another

  • 00:38:25 page product that index.

  • 00:38:30 See from the product rollers. Okay, we have details. Yes, let's give details.

  • 00:38:39 As you can see it is using the default layer. Okay. Okay. Now we can continue multiple.

  • 00:38:47 We've start files. So this is important.

  • 00:38:52 For most projects you will likely just have one view start file, which is most commonly

  • 00:38:57 placed in the root of your views folder. However, in larger projects, you might find it relevant

  • 00:39:03 to have more than one view start file usually to give more specific directions to views

  • 00:39:08 in a specific folder fortunately for us. The view start system is hierarchical meaning

  • 00:39:14 that asp.net MVC will look for a view start file in the same folder as the requested view

  • 00:39:19 first and then move up the folder hierarchy.

  • 00:39:22 if one is not found

  • 00:39:23 Okay, you can of course use this to your advantage lets me read it. You can of course use this

  • 00:39:32 to your advantage and create another view start file in one of your view subfolders.

  • 00:39:37 This view start file will then be used for all the views found in this folder the structure

  • 00:39:42 could then look like this? Okay, so currently product product pages we use for looking for

  • 00:39:51 the main new start. So under product, I will add another we've started.

  • 00:40:00 empty

  • 00:40:02 that's named as you start.

  • 00:40:07 Okay add in this view starts, so this was our route with start and it will be overridden

  • 00:40:15 for product pages here I will just call the layouts second so the product page is now

  • 00:40:24 we'll use the layout seconds by default

  • 00:40:26 Okay, let's see. So this will overwrite the route. We've starts route if status under

  • 00:40:37 leaves and this will start is under product. So all product pages will use the second layout

  • 00:40:44 as you can see now, let's check it from product. I am yes. It is using the second layout.

  • 00:40:51 however, if you use lecture

  • 00:40:56 Five list it uses the first layer. Okay. So now we have examples of port.

  • 00:41:08 Summary The View start file allows you to Define common logic, which will be automatically

  • 00:41:12 applied to all of your views like defining a default fallback layout as demonstrated

  • 00:41:17 in this article. You may also use it to Define other types of common logic like sharing information

  • 00:41:24 across all views by putting them in the view data from The View start file and then referencing

  • 00:41:28 it from your views will discuss the view data functionality in a later article. Okay. So

  • 00:41:34 let's make example of this as well. I will

  • 00:41:38 Sign and we have data that for example, let's tell something. Okay something equal to whatever

  • 00:41:49 we put in layouts second. So this will be available in

  • 00:42:03 okay to be set it I have to open and close servers.

  • 00:42:07 Code like this. Okay. So now I can access this something in all the pages that includes,

  • 00:42:17 okay.

  • 00:42:19 I'll give you they give back perhaps you have you back something.

  • 00:42:29 Yes, we work something it is. Dynamically that is not okay so seconds we start was available

  • 00:42:39 in for example index of product. So let's type it here. Okay, we walk something something

  • 00:42:49 like this.

  • 00:42:52 beta from view start

  • 00:42:57 Let's add a new line. Let's open the index of product page.

  • 00:43:08 This should be available in the pages that uses the second layout. However, it won't

  • 00:43:15 be available in the pages that uses the first layout.

  • 00:43:19 Product Dynamic. No, it's nothing because we didn't print it.

  • 00:43:26 Jaso index is details.

  • 00:43:33 Okay here we can see it here data from view starts. Whatever we put in the seat layout

  • 00:43:38 second. Okay. It is working as expected. This is great and

  • 00:43:47 Whatever if I type here something what would happen? Let's put a div here.

  • 00:43:54 some

  • 00:43:55 Warriors and I wonder how will it be displaying? So this is the master layout and it is being

  • 00:44:06 used in the index page of lecture 5.

  • 00:44:11 Okay somebody so you see this is put into the beginning of the page. Okay. So when we

  • 00:44:23 open the source code we see it here some values. Okay. So you see these leaves start is embedded

  • 00:44:31 inside.

  • 00:44:33 We're inside here.

  • 00:44:40 So this is using Master layout and then we open must alert. It uses rounded body. So

  • 00:44:46 as you can see it is coming.

  • 00:44:50 with your Valdez people tickets

  • 00:45:01 Someone is Master layouts.

  • 00:45:03 Or on this page, actually we use.

  • 00:45:16 Oh, I see. So this is even interesting as a layout. It uses the layout second index

  • 00:45:24 page. However, it also includes the master layout as well.

  • 00:45:32 Well, I mean the beef stock as well. Oh, yeah, you started editorial page. Okay, there is

  • 00:45:39 no confusion. So it is being embedded into where if you wanted it is being embedded into

  • 00:45:51 Runner body

  • 00:45:53 Okay. So when we check the source code we sit a minute here. Yes. It is embedded into

  • 00:46:03 top of the Randall body here. So you can even type something into will start and it will

  • 00:46:09 become available right after the render body like here.

  • 00:46:15 Okay, so let's continue.

  • 00:46:20 Okay, so there are also sections in layout before the designing. This is important.

  • 00:46:31 The layout allows you to reuse common content across multiple pages, but sometimes you might

  • 00:46:36 need to slightly vary the content rendered from the layout based in the actual page common

  • 00:46:42 scenarios for this would be to include some extra JavaScript code in the head section

  • 00:46:47 add an extra menu item to the menu or Implement a custom sidebar based on which part of the

  • 00:46:51 website. The user has navigated to this is where sections comes into the picture. They

  • 00:46:57 simply allow you to define a spot in the layout file. Where the page

  • 00:47:01 You may inject custom markup. Let's jump straight to an example so you can see what I mean.

  • 00:47:07 Okay. So in this page is p.net NB c-- tutorial calm. Actually. We are seeing that you see

  • 00:47:15 according to the page the right menu, right navigation is changing you see it is displaying

  • 00:47:22 at the top in which chapter VR and it highlights it like this and such. Okay, so let's continue.

  • 00:47:32 in you

  • 00:47:36 First we add a render section call to our existing layout file. If you haven't added

  • 00:47:41 a layout to your project yet. Just go back to one of the previous articles to learn how

  • 00:47:45 to do it.

  • 00:47:47 Okay, so we are going to add to render section like this render section put

  • 00:47:54 okay, so we added to our that our layout file so our index.html of lecture 5 uses layout

  • 00:48:05 seconds. Therefore I will open today at second here and I will add a render section footer

  • 00:48:13 inside it so what happens if we don't provide section photo, let's see it.

  • 00:48:27 And meanwhile, let's continue.

  • 00:48:32 Notice the call to render section. It's pretty much like render body because it simply defines

  • 00:48:37 the place where a certain type of content should be rendered. In this case. We want

  • 00:48:42 to render a section called footer near the bottom of the view. We should now Define this

  • 00:48:47 section in the pages views using the layout here are two different views which uses the

  • 00:48:53 layout but each of them will have a separate piece of content for our footer section. Okay,

  • 00:48:58 so if we don't provide this section in our

  • 00:49:01 You then we are getting an error invalid operation exception cannot find the section photos.

  • 00:49:09 So if you add this to your layouts, then you have to add put to section into all these

  • 00:49:18 that use they are seconds. Okay. So how do we Define different sections for different

  • 00:49:28 pages? It is like this so

  • 00:49:32 Let's find which pages are using layout second currently.

  • 00:49:36 Okay, and we start okay, the pages inside product and index.html. So, how do we Define

  • 00:49:50 section? It is like this you see it is highlighted as yellow section name is photos. So this

  • 00:49:58 is the boot which

  • 00:50:04 Page of index of lecture 5 so this will be printed wherever the section is located. I

  • 00:50:12 can even type this to the top like this and it will be displayed inside here after this

  • 00:50:24 div. So let's put the fruit in a different teeth.

  • 00:50:31 Let's said that different backgrounds colors.

  • 00:50:40 Perhaps let's make it.

  • 00:50:43 like this

  • 00:50:46 Let's add some padding on size.

  • 00:50:51 Okay, whatever we want and now footer will be rendered in here and we have defined a

  • 00:51:07 photodiode in our

  • 00:51:11 A Nexus HTML in product CSS HTML. Let's set a footer section at the top and this is the

  • 00:51:19 section is the footer section of Road out index or product pages and let's Round Up

  • 00:51:29 vacation to see how they are place it.

  • 00:51:34 By the way, the names must match probably they are say scans it sensitive as well.

  • 00:51:44 Okay, so the photo of page of in days of lecture 5 is visible. Let's check it for product as

  • 00:51:54 well.

  • 00:51:55 Okay, it says we have a problem.

  • 00:52:03 Or the different page I have to call the details page because I didn't add the futon in other

  • 00:52:12 pages.

  • 00:52:13 Yes, the photo is available here. However, I don't see the styling and what may be the

  • 00:52:24 reason

  • 00:52:28 or signing is applied. Okay, Alfonso is not.

  • 00:52:30 Or font size is also okay.

  • 00:52:35 Okay, everything is working as expected and this is the bar sections. So with sections

  • 00:52:47 we can.

  • 00:52:50 A design different leaves to display different information with using same layouts, okay.

  • 00:53:05 Notice the middle part where we Define content for the footer section. The syntax is quite

  • 00:53:10 simple the razor a character followed by the section keyword and then the name of the section.

  • 00:53:16 We want to Define inside the set of curly braces. We can then Define the content of

  • 00:53:21 the section in this case. We just use have a simple piece of text, but you are of course

  • 00:53:26 free to include markup as well. Let's do just that for our products View.

  • 00:53:32 Okay, so you can also set styling like this. It totally works. For example, let's do it

  • 00:53:45 for

  • 00:53:46 index of

  • 00:53:47 our lecture 5 like this and here's I will add another future. I will make

  • 00:54:03 equal to 200 pixels and won't

  • 00:54:06 Okay style. Let's make it italic. Okay, but when I restart this bill will also apply it.

  • 00:54:27 If you have already defined the underscore view start file as described previously, the

  • 00:54:32 two views will automatically use our layout page including the section with that in place.

  • 00:54:38 You will now see these views reuse the content from the layout file, but with varying content

  • 00:54:43 in our footer section. Okay. So this is how this food is displayed and for another page

  • 00:54:52 that uses the same folder.

  • 00:54:54 So which is product pages it will be displayed differently. Let's check it out.

  • 00:55:05 Your product and details. Okay here photo is displayed like this and it is displayed

  • 00:55:11 like this here. So it is totally up to us.

  • 00:55:17 Okay, there are also optional sections. So these are mandatory sections because when

  • 00:55:22 I now go to product Dynamic it will throw an error because in Dynamic we don't provide

  • 00:55:30 the section footage.

  • 00:55:32 Okay, so which one is the dynamic the dynamic is this page? There is no section footer therefore.

  • 00:55:42 It is failing. So there is optional sections for such cases.

  • 00:55:50 By default all sections are required just like the body is this means that if your page

  • 00:55:56 uses a layout with one or several defined sections your page view needs to Define all

  • 00:56:01 of these sections. If they don't you will receive an error. This is a great way to make

  • 00:56:06 sure that all your pages implements the required content. However, you can very easily transform

  • 00:56:13 a required section into an optional section when defining it

  • 00:56:16 Okay, so here as you can see we are getting an error now, I will fix it. How am I going

  • 00:56:24 to do that but I will open the layout section and master layouts or

  • 00:56:32 Okay layout section, you see our photo layer this here. I will provide extra parameter

  • 00:56:40 which is required. So the record is bullying therefore. I will set it false. Now when I

  • 00:56:48 open Dynamic page of products, it won't throw an error because we have changes that this

  • 00:56:57 section to be mandatory now it is not anymore mandatory.

  • 00:57:00 Therefore it will work without that section as well. Okay.

  • 00:57:08 However, we see it is this deal is seated included therefore we can see it here. Okay.

  • 00:57:19 So this is the way we do it.

  • 00:57:24 Notice the extra parameter when calling the render section command it simply states that

  • 00:57:29 this section is no longer required meaning that your pages can Define this section or

  • 00:57:33 not. If the section is not defined nothing will be rendered. That is also another way

  • 00:57:40 checking if a section has been defined that

  • 00:57:46 Checking if a section has been defined.

  • 00:57:49 When declaring a section is optional, it can be useful to know whether the calling page

  • 00:57:54 view defines this section or not. This allows you to Define some fallback content in case

  • 00:58:00 the content is not supplied by the page view like this.

  • 00:58:04 Okay, we can also include a message in the pages very large section is not defined. How

  • 00:58:13 do we do that? We had something like this into our layout now, we will see this message

  • 00:58:22 if the section is not defined. Okay. So it uses if section is defined as method here.

  • 00:58:31 It is coming from Microsoft asp.net code and we see resort resort, which is

  • 00:58:35 Section to find it. Okay. So the section is defined as here therefore no errors than let's

  • 00:58:41 try this. Okay you C-section is not defined and therefore we get General exposure message,

  • 00:58:49 okay.

  • 00:58:51 I can also put this inside this div div so it won't be anymore empty. Let's run it.

  • 00:59:04 Okay, let's read the summary summary sections allow you to define specific areas in your

  • 00:59:14 layout where you can inject content from the page view using the layout. This can be used

  • 00:59:20 in a wide range of scenarios as seen in the above examples. Okay. So this has a section

  • 00:59:25 photo and other page Dynamic doesn't have so the genetic foot of the message is

  • 00:59:33 This late. Okay, and now next is

  • 00:59:39 Okay, we've import files.

  • 00:59:46 Okay, before we continue with view Imports file, let's list the elements in our school

  • 00:59:55 library. So to do that I go to our lecture 5 and list.

  • 01:00:05 So here I will define an object of school library and it is available in models that

  • 01:00:14 are 4.

  • 01:00:19 Okay, let's say leap.

  • 01:00:28 Okay, so the school library.

  • 01:00:36 Takes which objects let's define them manage your name. Let's set it as for Kant and list.

  • 01:00:47 Let's set the list of books as well. Okay book a

  • 01:00:52 Look, babe.

  • 01:00:56 Then we will provide this model to our we've which we've situation we and iteration will

  • 01:01:08 is here look my mouse cursor here, so I will set something model.

  • 01:01:19 Okay by the veg we have put new keyboards used incorrectly. Okay, so now it is taking

  • 01:01:28 this model and in iteration model.

  • 01:01:34 today she will set the model as

  • 01:01:40 equal to lectures of we were sending its lecture one more model School library.

  • 01:01:53 Now I can iterate.

  • 01:01:56 Elements and how am I going to do that?

  • 01:02:04 And we like this look inside our model dot list of books. So let's define an unordered

  • 01:02:18 lists.

  • 01:02:20 Jay and his manager name

  • 01:02:23 Hey bloody.

  • 01:02:25 manager equal to model thoughts

  • 01:02:28 Okay manager name, why do you see it? There is a case difference. This is model with pick

  • 01:02:39 em and here it is with smaller. I am okay and then the others will be like here.

  • 01:02:50 Leave, okay, just right item.

  • 01:02:57 You can also name it as book name. So it would be a betters. Now. Let's open our iteration

  • 01:03:05 page for our iteration page. What do we use? Which action do we use? It is inside here.

  • 01:03:14 Thank you for controller. The action name is list, okay.

  • 01:03:23 And don't even continue.

  • 01:03:26 So I am just showing you this to just remind of our previous lectures because as I said

  • 01:03:35 some students are having hard time to understand I know that it is hard. Okay. Now the listing

  • 01:03:44 is working some of these iteration books only this page Library manager for fun book A book

  • 01:03:50 ebook see okay now we can continue it will import files.

  • 01:03:57 Okay, let's start the view Imports file.

  • 01:04:03 Asp.net MVC and razor comes with a lot of advanced functionality for working with your

  • 01:04:07 views. For instance. You can reference types from your own project or even from the dotnet

  • 01:04:13 framework in your views. But since the view is completely separate from the controller

  • 01:04:17 in this aspect. All you're using statements in the controller doesn't do anything in your

  • 01:04:21 view. This means that you will either have to use full references like this like this.

  • 01:04:32 Or is it alternative include the name space in your View using a using statement? Okay.

  • 01:04:37 So what does this means? Let's first understand. What does this mean? I'm going to open my

  • 01:04:46 school library. And Define data sets Okay for data set to be defined. I have to add

  • 01:04:56 using system data. Okay, so I

  • 01:05:01 I have added this into my reference and they see some Vance. Okay, I would actually make

  • 01:05:10 this data table.

  • 01:05:15 Okay.

  • 01:05:19 And I will make this as name instances.

  • 01:05:26 Okay, and in our lecture five controller, I will add some records to my data table and

  • 01:05:42 let's rename this first.

  • 01:05:45 Okay.

  • 01:05:48 Here's okay. It's okay Ross.

  • 01:06:02 And so for adding row it is expecting a array of values.

  • 01:06:11 Or data row. So let's add a new data row.

  • 01:06:16 You see it's automatically writing full pads of the data row. I mean since we didn't add

  • 01:06:25 its reference to here. You see some data of and it takes

  • 01:06:30 What's okay, so there is no.

  • 01:06:42 Maybe

  • 01:06:46 although we defined data roof.

  • 01:06:54 Looka here.

  • 01:06:57 stable

  • 01:06:58 actually, I have never

  • 01:07:02 defined it

  • 01:07:11 Let's find some example.

  • 01:07:18 I always use it with SQL queries.

  • 01:07:31 So it is made like this, okay.

  • 01:07:34 So data table dtdt clear columns name okay to edit. Let's set it up for us as well. And

  • 01:07:45 let's add a and b is equal to X then we Define data of Robbie equal to

  • 01:07:56 DT near of okay. So we Define it from the type of data table and we have columns or

  • 01:08:07 okay, let's make it something like this price and name. Okay, the Eternal book.

  • 01:08:18 Book price

  • 01:08:19 equal to one example something like this book not the name equal to

  • 01:08:33 Okay introduction to programming.

  • 01:08:39 And let's 10 book.

  • 01:08:41 Okay, this is not important. The reason I have done. This is how we are going to use

  • 01:08:49 it here.

  • 01:08:52 Okay, for example, let's ensure model dots.

  • 01:08:59 this

  • 01:09:01 now will this work?

  • 01:09:03 Okay, it says that for each statement cannot operate data table because the okay I have

  • 01:09:10 set this as Rose, okay.

  • 01:09:16 Now it is T model book name.

  • 01:09:24 And would it work like this? We don't have the reference of data of here. Can I type

  • 01:09:33 it later of here?

  • 01:09:35 No, it is not available in here. Can I type system data data row?

  • 01:09:44 Yeah, looks like I can give the full pads from its full name space. However, if it was

  • 01:09:52 something else it would be harder. So alternatively I can do this. Let me show you.

  • 01:10:00 Here, let's delete it. We don't pitches using system data data.

  • 01:10:10 Oh Stanley today tomorrow is not available. Why?

  • 01:10:22 SQL clients

  • 01:10:27 If I edit like this.

  • 01:10:40 Okay, now it is available as you can see I can either Define references like this or

  • 01:10:49 we can use we import which I am going to do because if I do it like this I have to change

  • 01:10:56 every wave file that I have. So we import is coming handy in this case.

  • 01:11:06 However, you would have to do this in all your views for all the namespaces you would

  • 01:11:10 like to have included. This is a lot of work, especially if you later decide to include

  • 01:11:16 another namespace in all your views, but fortunately asp.net MVC can help us out. The solution

  • 01:11:23 is called view Imports and is used by including a file called underscore view Imports CSS

  • 01:11:29 HTML in your project. Just like the underscore view start CSS HTML file the

  • 01:11:36 View Imports CSS HTML file is invoked for all your views before they are rendered. It

  • 01:11:43 allows you to Define common functionality and imports EG the already mentioned using

  • 01:11:48 statements.

  • 01:11:52 The underscore view Imports CSS HTML file can be used for more than just a common set

  • 01:11:57 of using statements though as of writing. It supports the following razor directives.

  • 01:12:02 Okay. So there are some directives such as using is Jake model in headed at taka truly

  • 01:12:07 Multicultural talk have a prefix. So let's add a video import to our project. Where do

  • 01:12:15 we edit we ended under shade it.

  • 01:12:20 Let me leave and it'll be named as we Imports. Okay, you have to name it exactly as that

  • 01:12:28 and then I will add using.

  • 01:12:32 System data, okay.

  • 01:12:36 Now, let's see if our problem is fixed on our list books iteration page.

  • 01:12:51 Okay, it is still saying that you are missing a reference.

  • 01:13:12 And why?

  • 01:13:17 Okay, let's find the reason.

  • 01:13:34 Okay.

  • 01:13:43 Oh, we had to edit on the gifts. Not on the Shaded. Maybe it is because of that. So let's

  • 01:14:18 move to

  • 01:14:19 four folders

  • 01:14:23 All right.

  • 01:14:26 Yes.

  • 01:14:28 Then here to leaves.

  • 01:14:34 Okay. Okay. It is located on this VF because I wanted to be globally available and not

  • 01:14:45 only under shaded. So let's see. Okay. Now it is available because now this reference

  • 01:14:55 is coming from with import and it will work as we expect. However, we didn't right.

  • 01:15:04 Features, so it won't be printed properly. I will fix in a moment. Okay?

  • 01:15:17 So let's write it as table.

  • 01:15:24 Okay, so first let's write the name.

  • 01:15:31 Okay. What what is we have? The first one is the name of the book. So to sitting and

  • 01:15:42 the second one is the price Okay, so

  • 01:15:45 okay, so the price will be equal to

  • 01:15:54 and then we'll be like this. Okay, so perhaps we can also even like like this it's not much

  • 01:16:10 important if I want to format this with

  • 01:16:15 Comic character, I mean thousands separators. How can I do that? I can write an extension.

  • 01:16:23 Okay, so it will be another good example. So under our classes, I will add Global classes.

  • 01:16:33 here

  • 01:16:34 Global clothes

  • 01:16:39 I will make this static public static us Global class. And here I will write an extension

  • 01:16:46 it will be public so extinct and format number. Okay, and it will take these dot object number

  • 01:16:59 object. What it is going to do is

  • 01:17:05 We will have a bunion double the result equal to none and if double dot right purse.

  • 01:17:15 Okay, and number of objects to string and then out results.

  • 01:17:32 If it is true, we would return results to string.

  • 01:17:41 With zero as we will return.

  • 01:17:52 Okay.

  • 01:17:53 Okay, which one not?

  • 01:18:01 Okay, now I can call this to shape this number. So I will copy and paste to show you the difference.

  • 01:18:13 The formatted an unformatted so instead of to drink I will call format numbers but as

  • 01:18:21 you can see it is not available. Okay, so how can I make it available? It is simple

  • 01:18:30 to make it available. I will go to my with import using.

  • 01:18:34 Lecture 1 and classes dots nothing. I think it should now become available.

  • 01:18:46 Yes, now this is available. You see you see it is getting string extension from T-Mobile

  • 01:18:54 format number and then I run the iteration and iteration is index action of list. I believe

  • 01:19:07 yes list.

  • 01:19:11 Let's see.

  • 01:19:15 Okay, then lecture 5 list, okay.

  • 01:19:28 Okay, we have some.

  • 01:19:36 issue

  • 01:19:38 we are able to see this but

  • 01:19:46 this one is not available.

  • 01:19:55 And why because this is probably null.

  • 01:20:03 I know the reason because we have composed this data table. However, we didn't assign

  • 01:20:12 it to a large model data table, which is here will be equal to DT. By the way. This will

  • 01:20:19 own a sign its reference. Therefore. This is totally performance point of view of same.

  • 01:20:28 This is not copying entire object into this one is just reference copying.

  • 01:20:37 I'm done. Okay.

  • 01:20:44 Okay, now it is available.

  • 01:20:48 Okay, you see we have incorrectly.

  • 01:20:55 Set the columns.

  • 01:20:57 First one is priced second. One is name. Therefore we have need to change their order this

  • 01:21:07 Now it should work as we wanted.

  • 01:21:17 Actually, we should move this into the yes.

  • 01:21:40 Where's let me show you.

  • 01:21:42 Anr model School library, I will set it here. So I will have a constructive Public Schools.

  • 01:21:57 I'm ready and in the Constructor, I will add the columns like this. Okay, and then on here?

  • 01:22:12 These days are all will be equal to live. That is he someone is data me bro, and this

  • 01:22:26 is more proper way, I think.

  • 01:22:31 That book as soon as now should look better. Yeah.

  • 01:22:44 The previous one would work as well, but I think keeping the table columns in our model

  • 01:22:56 is Parish approach.

  • 01:22:59 Yes introduction. So this is non formatted price and this is the form of the price. I

  • 01:23:06 could also perform at it it as Turkish separated with thought or european does it is up to

  • 01:23:16 you? All right. So now we know the we've started and even import. Let's see the difference

  • 01:23:23 underscore view start versus underscore view Imports.

  • 01:23:28 At this point you may have noticed that the underscore view start and underscore view

  • 01:23:33 Imports files are quite similar. They both allow you to implement functionality that

  • 01:23:38 will be automatically applied to your views. However, there's a very important difference

  • 01:23:44 any using statements added to the underscore view start file is scope to this file and

  • 01:23:48 doesn't apply to the actual views on the other hand. The underscore view Imports file is

  • 01:23:54 specifically designed to extend the scope to the Views allowing your views to take advantage

  • 01:23:59 of

  • 01:24:00 Using statements defined in the underscore view Imports file. Okay, so we can also give

  • 01:24:06 an example to this to explain the difference.

  • 01:24:13 For example, let's think about

  • 01:24:19 An Essence what can it be perhaps task?

  • 01:24:30 Okay, so

  • 01:24:32 I would write a simple cortinas.

  • 01:24:45 Okay, let's say that I want to write this code in my by the way. I probably we are not

  • 01:24:57 able to start new task in me, but I'm not sure what is already available.

  • 01:25:11 Nothing comes to my maybe stream.

  • 01:25:14 Can maybe try this? I think we live here.

  • 01:25:19 Okay, so the string will let is not available here because it uses system dot text when

  • 01:25:28 I edit to weave start like here.

  • 01:25:39 It won't be still available in here. Okay, still not available as you can see because

  • 01:25:45 the using only applies to restart for example, now I can use string Builder. Here's my business

  • 01:25:55 near Builders as you can see, but this applies to only scope of BF start. However if I added

  • 01:26:04 to here

  • 01:26:05 No, it will be available in my old CSS HTML files. Now as you can see I can use it as

  • 01:26:17 I want.

  • 01:26:19 will something

  • 01:26:20 we'll do whatever we want now we can use it. So this is the difference between view start

  • 01:26:30 and we import if you want to import some libraries into your views, then we import is the file

  • 01:26:40 that you have to use and it has to be positioned under views folder here. If you position it

  • 01:26:47 under for example, let's say product then only product pages would be able to use

  • 01:26:53 This I believe for example, let's try it.

  • 01:26:58 Okay, now I will copy and paste into one of the product.

  • 01:27:04 Okay here let's see. Yes, it is working here. But on index of CSS HTML it won't be available.

  • 01:27:15 So it is checking from the lowest so upper. So then we put we will put on the product

  • 01:27:22 the will import scope is only available under the waves under the product folder. Okay,

  • 01:27:30 however when I move it to

  • 01:27:33 Root of lives. It will be available all waves inside waves. It's seated wouldn't be available

  • 01:27:40 here. So this wouldn't work because the test is under different folders. So the folder

  • 01:27:46 hierarchy does matter to us if I want it to be available here as well then.

  • 01:27:56 Yeah, there is no upper folder. Therefore. I have to also add it here or

  • 01:28:08 I have to Define another leaving Port under this folder as well. Okay, you get the idea

  • 01:28:16 of the Scopes they will start and we import are available under the which scope they are.

  • 01:28:25 This is like classes and methods and so if you are an upper level then you can access

  • 01:28:33 it. Let me show what does this?

  • 01:28:37 this mean for example

  • 01:28:43 Let's say I have another class. Here's public test.

  • 01:28:48 Okay, and

  • 01:28:49 okay, of course not this way prop. Just think.

  • 01:28:59 Okay gigi equal to test and now can I access this GG here? No, because its scope is only

  • 01:29:13 under test. For example if I write them.

  • 01:29:23 method like this

  • 01:29:24 Okay test a GG is equal to something like this. Okay, so it is same if I Define it here

  • 01:29:38 I can access it both here and here or if I Define it here. This is only available under

  • 01:29:45 the same hierarchical level. Okay?

  • 01:29:50 Alright, the next chapter is routing and routing is really important. Therefore. I will start

  • 01:30:00 routing next week. I want you to understand this which perfectly fine and not this one.

  • 01:30:18 Let's not what we have seen this week.

  • 01:30:26 Okay, so

  • 01:30:28 Okay.

  • 01:30:42 So what we have seen?

  • 01:30:50 We have seen there.

  • 01:30:57 layouts

  • 01:30:58 Okay, what is

  • 01:31:18 in web design?

  • 01:31:23 Okay.

  • 01:31:25 how to design

  • 01:31:31 layouts in asp.net

  • 01:31:34 Cora me see projects

  • 01:31:38 What is the era?

  • 01:31:46 availability

  • 01:31:48 of I will fix the incorrectly type of keywords worst English words later laters.

  • 01:31:56 Is yes, but Nets.

  • 01:32:01 Let me see. What are the default has views.

  • 01:32:11 receive Yves VV porch weaves

  • 01:32:16 such

  • 01:32:18 Okay, you see the restart?

  • 01:32:27 how to you start and what is the

  • 01:32:51 how to

  • 01:32:53 What is k?

  • 01:33:00 Okay.

  • 01:33:06 What are the sections in?

  • 01:33:26 layouts of s box

  • 01:33:30 Absolutely fine and use sections in let's not let me see leaves.

  • 01:33:44 how to make a section optional

  • 01:33:51 Okay, I will fix the naming later. I'm just taking notes and

  • 01:33:58 what you live in Port?

  • 01:34:13 Okay.

  • 01:34:15 please

  • 01:34:18 includes scripts or libraries into is by using IF start or import.

  • 01:34:37 Okay.

Clone this wiki locally