Asp.Net MVC Conventions

Slides:



Advertisements
Similar presentations
Publication Module using back end interface. Institution Data Entry Add Documents. Edit/Delete Documents that are added but not yet sent to Institution.
Advertisements

Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Introduction to MVC Action Methods, Edit View, and a Search Feature NTPCUG Dr. Tom Perkins.
Access Lesson 2 Creating a Database
Collaborating with Outlook 2002 and Exchange 2000.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Business Optix Library Service – Workflow
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC - Models.
Mail merge letters are used to send the same or similar documents to many different people. Since they contain the recipient’s name, address, and other.
XP Chapter 2 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Building The Database Chapter 2 “It is only the farmer.
Copyright © 2002, Systems and Computer Engineering, Carleton University Hashtable.ppt * Object-Oriented Software Development Unit 8.
Working with GridView Control: Adding Columns. Adding Buttons to a Bound GridView: 1. Drag the WebProduct table from Data connection to a page 2. Demo.
Fourth R Inc. 1 WELCOME TO MICROSOFT OFFICE OUTLOOK 2003 INTRODUCTORY COURSE.
Creating Interactive Polls With Video Clip Current as of
BIT 286: Web Applications Lecture 10 : Thursday, February 5, 2015 ASP.Net Form Submission.
What is Web Site Administration Tool ? WAT Allow you to Configure Web Site With Simple Interface –Manage Users –Manage Roles –Manage Access Rules.
The Problem of State. We will look at… Sometimes web development is just plain weird! Internet / World Wide Web Aspects of their operation The role of.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Bookstore Application: Middle Tier Introducing Code-Behind Files, Session State.
Getting started with ASP.NET MVC Dhananjay
HCI Prototype Presentation by Richard Gerard Gator Growlers CEN4020.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
Session, TempData, Cache Andres Käver, IT Kolledž
03 | Developing MVC 4 Controllers Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek.
22 Copyright © 2009, Oracle. All rights reserved. Filtering Requests in Oracle Business Intelligence Answers.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
MVC Controllers TestsMigrations Ye Olde Internet Model DB Server Router View Browser Today’s focus Controller.
Jim Fawcett CSE686 – Internet Programming Summer 2010
Jim Fawcett CSE686 – Internet Programming Spring 2014
Web-based Information Science Education
Android Content Providers & SQLite
An introduction to ASP.Net with MVC Nischal S
About the To-Do Bar in Outlook
Creating Oracle Business Intelligence Interactive Dashboards
Jim Fawcett CSE686 – Internet Programming Spring 2012
Social Media And Global Computing Introduction to The MVC Pattern
COM components + persistent storage = objects
Chapter 3: Using Methods, Classes, and Objects
MVC Partial View.
View In MVC Mo Rezai.
Active Server Pages ASP.Net
Jim Fawcett CSE686 – Internet Programming Summer 2008
Controllers.
ServiceLink Training Video Entering Job Referral Outcomes
Physician Tips and Tricks
Access Lesson 2 Creating a Database
Social Media And Global Computing View and Session Data
MIS Professor Sandvig MIS 324 Professor Sandvig
Passing Parameters by value
Social Media And Global Computing Managing MVC with Custom Models
Data Structures and Database Applications View and Session Data
MS Access and Database Connections
WORKING WITH SHARED DOCUMENTS
Chapter 7 Searching Your Products
Lecture 5: Functions and Parameters
© 2016, Mike Murach & Associates, Inc.
MVC Controllers.
MVC Controllers.
Rules and Tips for Good Web Programming (and Programming in General)
MVC Controllers.
Automation and IDispatch
Asp.Net MVC Conventions
Share & View Functions of Portfolio
MIS Professor Sandvig MIS 324 Professor Sandvig
3.3 – Invoke Workflow File Exercise 3.2: Extract as Workflow
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Asp.Net MVC Conventions Jim Fawcett CSE686 – Internet Programming Spring 2012 Asp.Net MVC Conventions

Asp.Net Conventions The MVC framework uses three kinds of conventions: Structure conventions Model structure Directory structure Naming conventions Controller methods & views Placement conventions

Model Structure Models are C# classes All models reside in ./Models folder Have public properties Controller methods may name a model When controller method is invoked it is passed an instance of model named as its method argument Views can be typed to use a specific model Model’s public properties are populated on postback if their names match names used in the view.

Naming Conventions Default controller is HomeController.cs Controller names end in Controller Default controller defined in Global.asax.cs Default view is Index.aspx Default view defined in Global.asax.cs Controller methods are names of views Public ActionResult Index() { … }

Placement Conventions Controllers are placed in folder Controllers Views are placed in subfolder named with controller name: ./Views/Home/Index.aspx All models are placed in folder named Models

Adding a New Controller Right-click on Controllers folder and select Add Controller You can elect to add “Create”, “Update”, and “Details” controller methods Action methods often return a view using the controller method View(). If no arguments will return view of same name as method You can supply names of both a view and a model to be used.

Adding New View Right-click on controller’s action method name and select Add View You can now elect to make the view strongly typed by selecting an existing model (the Add View dialog calls that “View Data Class”) You can elect to select View Content: Create, Delete, Details, Edit, List List, for example, provides a nicely structured table presentation of records from your model

Passing Data to Controller Controllers are created with each call So you can’t save data in controller method from call to call You can save data in ViewData dictionary or in Session. When controller method is called any model arguments are passed newly created instances of the named model. On PostBack data from view is bound to model

Passing Data to a View There are two main ways of getting data from a controller method to its view: Add data to ViewData dictionary, shared by controller and view Pass model as argument of controller method View(aModel)

Returning Data from View Controller methods receive data in several ways: A get request (from an ActionLink) may send an index into a model list. A PostBack (post request) sends its form data back to the Asp.Net Request Dictionary. PostBack data is automatically bound to the view model held by the method if the view is strongly typed.

ViewData vs. ViewBag vs. TempData vs. Session ViewData: dictionary – key/value lifespan: only current request; redirects cause it to be null ViewBag: wrapper around ViewData, access it as properties lifespan: same as ViewData TempData: dictionary – key/value lifespan: until the view is fully loaded; works with redirects Session: dictionary lifespan: until cleared http://www.dotnet-tricks.com/Tutorial/mvc/9KHW190712- ViewData-vs-ViewBag-vs-TempData-vs-Session.html

That’s All Folks!