Previously on Part 3, I have explain on how we could code on loading partials when needed. Part 3 method is best used on partials that deals with forms and require model parse on loading the view. On this Part 4 tutorial, I'll explain on how we could code dynamic partials that do not require loading delay.
This tutorial will load partial on page load but will set the partial on hidden(but if you would like to display a default partial to being viewed, I'll explain on this later). Some would ask why should I use Partial view instead dump all the codes on one .cshtml files? My answer is simple, to structured and organized my view. This way, I wont have trouble when I need to debug my view codes in future.
Code for main Index.cshtml:
Code for Partial View _1.cshtml
Code for Partial View _2.cshtml
Code for Patial View _3.cshtml
Code for Partial View _4.cshtml
Now, you should press F5 (On Visual Studio 2010) and see how it works in real.
So, it's simple isn't it? This can also be done with PHP and other web programming language and it's useful to display a page which do not have forms to submit. I'll cover more on how we could make dynamic partial view to display partials with forms and POST the forms value by forms on submit and still preserve the current viewing on my next tutorial.
Until then, please enjoy your MVC 3 exploration and happy programming. Don't forget to leave comments on how to improve my skills and also please Like this post on Facebook and Blogger.