Presentation is loading. Please wait.

Presentation is loading. Please wait.

Getting started with ASP.NET MVC Dhananjay

Similar presentations


Presentation on theme: "Getting started with ASP.NET MVC Dhananjay"— Presentation transcript:

1 Getting started with ASP.NET MVC Dhananjay Kumar @debug_mode http://debugmode.net

2 Agenda  Getting started with ASP.NET MVC  Understanding Controllers  Understanding Views  Understanding Model  ViewBag, ViewData, and TempData  Strongly Typed and dynamic views  Child Action and Partial Views  Areas  Database first approach  Code first approach  Using client side libraries like jQuery, Ignite UI

3 Give Away Tweet your experience about webinar using the hashtag #Infragistics or tag @infragistics to win cool goodies from us.

4 I am Dhananjay Kumar  Developer Evangelist @infragistics  6 times Microsoft MVP  @debug_mode  debugmode@outlook.com  http://debugmode.net http://debugmode.net

5 ASP.NET MVC Model View Controller

6 ASP.NET MVC Clean separation of concerns Enables or support Test Driven Development Easy integration with client side libraries like JavaScript, jQuery, and Ignite UI Developer has full control over the rendered HTML Due to stateless nature and URL routing, highly optimized for search engines Supports Authentication, authorization, configuration, compilation and deployment

7 Controller A Controller does all the actions in MVC. It handles user interactions or inputs. It passes user's data to a Model and selects a View to render on the UI. A Controller is a class It contains one or more methods called Actions An Action can return a simple string or a selected View to the UI Action takes all browser requests or user inputs It retrieves data from the Model It selects the View to be rendered on the UI

8 Controller

9 Controller Demo

10 View Views are the components that display the application's user interface (UI) It renders user interface It contains markup to be rendered with the ViewEngine There are two kinds of ViewEngine in MVC- Razor and ASPX engine Controller may returns View View renders data from the Model returned by the Controller Controller can send data to View

11 View

12 View Demo

13 Model Model is a class which represents the problem domain. Model implements logic for the application data. Model is a class It is accessible to both the view and the controller Views renders data from the model Controller can pass data from model to the view Model class contain the application logic Model is place of the ORM or Data Access frameworks

14 Model Application data logic ORM Business Logic

15 Model Demo

16 Passing Data ViewBag dynamic object to pass data from controller to view ViewData dictionary object to pass data from controller to view TempData dictionary object to pass data from one controller/action to another controller/action

17 ViewBag and ViewData

18 Demo on ViewData and ViewBag

19 ViewBag and ViewData

20 TempData

21 TempData is used to pass data from one HTTP request to next HTTP request. In other words, TempData is used to pass data from one controller to another controller or action to another action. TempData is property of BaseController class. TempData stores data in session object TempData is property of ControllerBase class To read data Typecasting and null checking is required. Type of TempData is TempDataDictionary. TempData works with HTTP redirection like HTTP 302/303 status code

22 TempData Demo

23 Types of Views Views Dynamic Views Strongly Typed Views

24 Different kinds of View Demo

25 Child Action Child Actions are the action methods which can be invoked within a view. Child Actions are the action methods which can be invoked within the view This is used to work with the data in the view, which are not related to the main action method In ASP.NET MVC any action can be used as a child action To use an action only as a child action and attribute it with the ChildActionOnly. It will make sure the action is not called by any user request and will only be used in the view.

26 Child Action Demo

27 Areas A MVC application can have any number of Areas Each Areas has its own controllers, models, and views. Physically Areas are put under separate folders. Areas are useful in managing big web applications

28 Areas Demo

29 Q& A ?

30 Summary  Getting started with ASP.NET MVC  Understanding Controllers  Understanding Views  Understanding Model  ViewBag, ViewData, and TempData  Strongly Typed and dynamic views  Child Action and Partial Views  Areas  Database first approach  Code first approach  Using client side libraries like jQuery, Ignite UI

31 What Infragistics can offer you? We welcome all of you to take advantage of a FREE 30 Day Trial by downloading the product at: http://www.infragistics.com/products/ultimate/downloadhttp://www.infragistics.com/products/ultimate/download Please reach out to us at Sales-India@infragistics.com for any follow up questions you may have. We welcome the opportunity to assist you.Sales-India@infragistics.com


Download ppt "Getting started with ASP.NET MVC Dhananjay"

Similar presentations


Ads by Google