作者:empty 页数:332 出版社:empty |
About the AuthorsAndrewS le meris currently a Senior Technical Architect for Perficient in AustinTexas, He has worked as a software engineer, architect, trainer, and author since 1998when he left the military.HeisafrequentcontributortoDotNetslackers.com, hostofDotNetRadio.com, author of ASPNET 3.5 Social Networking, and a member of theASP Insiders group.Andrew has provided consultancy to many companies on the topicsof e-commerce, social networking, and various other business systems.He has workedwith e Universe, Point Vantage, Callaway Golf, Gul dance Software, Intermix Media, FoxInteractive, LampsPlus, and Lender Processing Services, to name a few.In addition to hisdaily duties, he also conducts classes in.NET, C#, and other web technologies, blogs onnumerous topics(blog,andrewsicmer.com) .and works on various community projectssuchasNveCookbook.com.You can find Andrew Siemer on Twitter at was i emer, as wellas Facebook, Linked In, and various other soc lal sites.Richard Kimber has been working with web technologies for over 15 years.Primarilya.NET developer, Richard has worked in abroad range of development environmentsfrom the financial services industry to new media and marketing.He now runs a web andmobile consultancy company called Dogma Creative with his wife Katie.Tim Cromarty has been working in IT for well over 20 years in a variety of positions andresponsibilities, In the late'80s'he was an Oracle developer, and worked for a variety ofcompanies including Oracle UK, ITV, Banks and Local Government.Then, in the late'90s'-he became involved in Java and web development working primarily for theEuropean offices of US-based organizations.More recently, Tim has held a number ofdirector level positions managing large multi-million pound global organizations.As a developer, he enjoys learning new programming languages, techniques, andpractices.He has been using.NET since the first version and has also spent plenty oftime developing inC, Java, Perl, PHP, SQL, PL/SQL(he could go on.) , but his currentfocus is.NET-especially MVC.Based in Hampshire, England, Tim is currently an independent software consultant andtechnologist providing technical and managerial consultancy in Microsoft ASP.NET, MVC,j Query, JavaScript and AJAX, as well as managing multiple web development projects,e-commerce, and community websites.Hisblogcanbefoundathttp://blog.clicktricity.com.lam married with an amazing 4-year-olds on.My ambition is to stop lying about my agewhen I reach 30.My wife think sIma nerd because my idea of relaxing is to read aprogramming manual lTo my wife Jessica-l love you!Thankyou for stand ngwthmethrougnyetanother book project.Katie, thankyou for your constant support and encouragement.To myGranddad who passed away earlier this year, thankyou for showing mewhat can be achieved.
About the Reviewers
Buu Nguyen is a Microsoft MVP in ASP.NET.He is currently the VicePresident ofTechnology at KMS Technology-a global software services company.During his pastseven years of experience in software development, he has been involved in thedevelopment of multiple applications ranging from Java and.NET enterprise applicationsto RubyonRails web applications.Buu is an active community participant who has conducted training for Microsoft,published technical articles, developed opensource software, and been a frequentspeaker at technical conferences, including those organized by Microsoft.Besides his industrial and community engagement, Buu is apart-t me university lecturerwho teaches courses in software architecture, J2EE, and ASP.NET.Baskin I.Tap kan has recently joined Verifications, Inca consumer reporting agencyspecializing in systems integrations-as a senior software/webdeveloper/architect.Baskin is a technology evangelist and has been programming for over 20 years, startingwith Turbo Pascal and QBasic.He has be encoding in the.NET framework since itsrelease and now focuses on the ASP.NET MVC and WCF Services.Prior to joining theVerifications Inc., he has been a software architect at Health land, Inc., a consultant withMage nic, and a systems design engineer at Imation Corporation .He has over 12 yearsof industry experience in manufacturing, healthcare, education, and consumer services,working on various database-driven applications.Baskin holds a Master's Degree inElectrical Engineering from the University of Wyoming.Baskin is an avid windsurfer andan upcoming kite boarder currently residing in Twin Cities, MN.He enjoys his few weeksof vacation at the Columbia River Gorge.Support files, eBooks, discount offers, and moreYou might want to visit www.PacktPub.comfor support files and downloads related toyour book,Did you know that Pack t offers eBook versions of every book published, with PDF andePub files available?You can upgrade to the eBook version at www.PacktPub.comandas a print book customer, you are entitled to a discount on the eBook copy.Get in touchwithusatserviceepacktpub.comfor more de talls.At www.PacktPub.com, you can also read a collection of free technical articles, signupfor a range of free newsletters, and receive exclusive discounts and offers on Pack t booksand eBooks.
PrefaceTen years ago, ASP.NET provided software developers with a means to write complex webapplications with their existing WindowsForms sk ll sets.Today, it continues to be a robustframework for writing scalable applications, from small e-Commerce to enterprise-level CRMBut ten years later, with many business critical applications existing solely on the Web, theForms paradigm is less relevant.ASP.NET MVC, based on RubyOnRails, is now in its second release, with a third around thecomer-a powerful framework based on new and old ideas, ASP.NET MVC allows the developerto work with web protocols and standards, while still making use of the industry-standarddevelopment environment-VisualStudio.By example, this book will take you through the key areas of ASP.NET MVC.Well look atthe MVC structure, data access, and ASP.NET MVC's compatibility with client scripting anddependency injection.With a minimal knowledge of web development, this book wil help youbuild scalable web applications with relative easeWhat this book coversChapter 1, Working with the View.The view is possibly the most recognizable component ofASP.NET to a webforms developer, with its familiar ASPX extension.However, the differencesare significant; we will explore the concepts of View Data, strong y typed Views, and helpers inthis chapter.Chapter 2, Taking Action In Your Controllers.For every view there Is an action and a controllerto host it, Torit is the action that you navigate to in your browser.The view is merely a templateto be called upon, In this chapter, we will leam about controllers and their actions, particularlythe resulting types that are not necessarily HTML.Chapter 3, Routing.If the action is a destination, routing is how you get there.The structure ofa URL is an important aspect of a site's navigation; it should read ikea map, showing you whereyou are and give hints as to where you can go.Well ook at how you can manage URLs to createuser-friendly sitemaps, control errors, and provide a hackable APlin to the current view.Chapter 4, Master Pages.Don't Repeat Yourself; every good developer should keep thingsDRY.Master Pages are one of many conventions for doing just that.Here, we'l look at creatinga site-wide look and feel, nesting, and shared functions.Chapter 5, Working with Data in the View.The difference between static HTML and dynamicallygenerated sites is usually the data.in this chapter, we'll look at how easy it is to manage data inthis powerful new framework and how it reintroduces old concepts to powerful effect.Chapter 6, Working with Forms.Forms are the heart of the interactive Web, working at thebrowser's most basic level; they can be enhanced to provide a rich and intuitive experienCe.ASP.NETMVCprovidesextraordinarycontrolovertheseelements:we'llseehowwecancapitalize on this control with client scripting and templates.Chapter 7, Simplifying Complex Applications.ASP.NET MVC has been designed from theground up to be tested, extended, and improved.Here well see how third-party libraries canbe used to extend existing functionality or provide a completely new set of options.Chapter 8, Validating MVC.Validation is the key to any application that accepts input of anykind, but where should it be implemented-on the client where it is most responsive, in thebusiness logic where it is most central, or in the data layer where it is most secure?ASPNETMVC provides a simple yet powerful framework for defining validation from a central locationthat is decoupled from the data layer, validation that makes use of client scripting withoutbeing dependent on it; and with all this, keeping the validation DRY.In this chapter, well lookat data annotations, client-side scripting and remote validation.Chapter 9.Data Access and Storage.With so many options for storage these days, you mightfind that you dont want to tie yourself to just one.In this chapter, we'll look at the repositorypattern and how, when used in conjunction with dependency injection, we can create anapplication that, with minimal work, can be connected to XML, SQL, or test datasources.Chapter 10.Application, Session, Cook les and Caching.Application optimization has neverbeen easier with ASP, NET MVC.In this chapter, well look at session management usingsession and cookies, and howto cache different aspects of the application to provide thebest performance.What you need for this bookThis book assumes that you reusing ASP.NET MvC 2, but most recipes will work in version 1and the latest release candidates of version 3 with only minor modi tication, To run ASP.NETMVC 2, you will need atleast Microsoft VisualStudio 2008or Visual WebDeveloper 2008, forwhich ASP.NETMVC2is available as a separate download.If you're already using V52010orVWD 2010, ASP.NETMVC2is already installed.If you're not using any version at the moment,I would recommend downloading and installing Visual WebDeveloper 2010, it's free andpretty great.A few of the chapters have dependencies on free third-party libraries, which aredescribed in the chapters.However, Chapter 9 also assumes the installation of SQLServerExpress(2008orabovel; this was likely part of your original VisualStudio installation, but irnot, it is also a tree download.
Table of Contents
Supporting content hierarchies with a custom Route Handler
Creating a blacklist route constraint
Chapter4:MasterPages
Introduction
Howto create a master page
Determining the master page in the Action Result
Controlling which master page is used with a view baseclass
Setting the master page from a controller baseclass
Passing data to the master page
Rendering data in a master page from another view
Creating nested master pages
Chapter5:WorkingwithDataintheView
Introduction
Reintroducing for and for each
Handling an array of checkboxes
Handling an array of radio buttons
Working with a page able set of data
Howto navigate sortable data
Deleting a record with an intermediary Are you sure?page
Adding aj Query delete link with confirmation
Master/detail page within line details via j Query and a partial view
Creating a master/det all page with modal pop-up and JSON
Chapter6:Workingwith_Forms
Introduction
Using HTML helpers to create forms
Building a custom HTML helper to display a WYSIWYG
Centralizing create and edit forms for reuse
Adding custom attributes to form elements
Defining a default button with j Query
Hija xing a form with j Query
Performing an auto post-back with a select list
Autocomplete with j Query UI
Chapter7:SimplifyingComplexApplications
Introduction
Centralized formatting of common types with templated helpers
Making templated helpers for custom types
Using areas to separate application components
Creating a portable area to use across multiple applications
Using input builders of Mvc Contrib
Generating forms with Html.InputForm()
Leaving breadcrumbs for your users with Mvc SiteMap
Displaying tabular data in a grid
Chapter8:ValidatingMVC
Introduction
Basic input validation
Data annotations
Client-side validation with j Query
Custom validators
Remote validation with j Query
Chapter9:DataAccessandStorage
Introduction
Mocking your data layer with NBuilder
Adding support for LINQ to SQL
Going oldschool with A DO.NET
XML documents a