Murach's ASP 4 Web Programming With C 2010

Transcription

TRAINING & REFERENCEmurach'swebprogramming withC# 2010Anne BoehmVa.I J)Joel MurachMike Murach & Associates, Inc.1-800-221-5528 (559) 440-9071 Fax: (559) 44(M)963murachbooks@murach.com www.murach.com

ExpandedSection 1Chapter1contentsThe essence off ASP.NET webAn introduction to ASP.NET webAnprogrammingprogramming4introduction to web applicationsTwo pages of a Shopping Cart applicationThe hardware and software components for web4applicationsHow static web pages workHow dynamic web pages work810How state is handled in ASP.NETAn introduction to ASP.NET12applicationsapplication developmentThe software you needThe components of the .NET FrameworkThree environments forAquickpreview ofThe files used by the16ASP.NET application works2020applicationThe aspx code for the Order formThe C# code for the Order formHowChapter 2anASP.NETHow toisapplicationdevelop2224compiledand26runone-page weba18CartanShopping1414developing ASP.NET applicationshow6applicationHow to work with ASP.NET web sites32How to start32How to addHowtoa newweb siteweb form toaweb siteaHow to add folders and files toHow to openorHow to useThedesignHow to34work with the Visual Studio IDEuseHow to addcloseanDesignaweb siteexisting web siteview to build a web form36384042of the Future Value form42flow44alayouttableto aform46table46How to add server controls to a form48How to set the48How to add text to the cells ofCommonaproperties of the controlsproperties for web server controlsHow to work in Source andHow touseSource view toHow touseSplitHow to use codeviewtoSplit viewsmodifythework with thedesigndesign5052525456snippetsThe aspx code for the Future Value form58How to add validation controls to a form60An introduction to the validation controls60How to62usetherequired fieldvalidatorHow to use the range validator62How to add code to64How touseHow touseaformthe Code Editor64page and control eventsThe C# code for the Future Value form6668

ExpandedHow to testHowwebaapplication70web site with the built-into run adevelopment70serverHow to review the HTML that's sent to the browserChapter 3How toThedevelopCartShoppinga72multi-page web application78applicationThe Order pageThe Cart page class toaSix skills forHow to createrename aHow tochangeuseShopping Cart applicationor84with86multiple web formsstarting files and folders8688starting webtransferform88to another page9092cross-page postingHow to code absolute and relative URLs94How to create and use data sources96How to create96Access dataansourceHow toHowconfigure an Access data sourceto bind a drop-down list to a data sourceHow touseHow toC# code to get data fromadata98100102sourcesession stateuse104How session state works104How to work with data in session state106The code for theShopping Cart application108The code for the Product class108The code for the Cartltem class108The code for the CartltemList class110The aspx code for the Order pageThe C# code for the Order page112The aspx code for the CartpageThe C# code for the Cart118116120pageChapter 482web siteweb formtheHow to redirectbytheweb site withHow toHow toaworkinga7880The files and folders usedHow to addcontentsHow to test and debugHow to testHowananASP.NETapplicationapplicationusing the ASP.NET Development Server. 128application with the default browseran application with a browser other thanthe Exception Assistant128to test anHow to testHow touseHow to testanHow to createaHow to testaHow to testanapplication usingthe defaultIISlocal IIS web sitefile-system webapplicationHow to use the130132134134site with IISfrom outside of Visual Studiodebugger136138140How tousebreakpoints140How tousetracepoints142How to work in break modeHow to control the execution of144anapplication146How tousethe Autos, Locals, and Watch windows to monitor variables148How tousethe Immediate window to work with values150

Expanded contentsHow touse the Trace feature152How to152interpretTrace outputHow to create customtrace5A crash154messagesHow to write informationChapter152How to enable the Trace featuredirectlyto the HTTPoutputHow162HTML elementscodingto work with162HTML using Visual Studio164How web server controls are rendered166How to code HTML documentsThe basic structure ofTheThe156in HTML and CSScouseAn introduction to HTMLBasic rules forstream168HTML documentan168Page directiveDoctype declaration170170How to code block elements172How to code inline elements174Basic skills forHow toincludeCSSusingCSS ina176webHow to code CSS rule setsHow to code selectors for176pageand comments178and classeselements, IDs,180A Future Valuepage that uses CSS182The aspx code for the Future Value formThe CSS for the Future Value form184Visual Studio features forworkingHow to work withDesignHow to addstylestylesfrom186with CSSview190rules192How to create and edit externalHow tousetheHow tousethe CSSHow touse190style sheets194window196Apply StylesProperties windowthe Manage Styles window198200Section 2 Basic ASP.NET skillsChapter 6How to work withAnintroductionto server controlsofservercontrolsThe din this210chapterHow to handle control eventsHow to use accesskeysHow to set the focus212with webon awebserverservercontrols214control214How to set the default button control214How to work with button controlsHow to work with buttons, link buttons, andHow tousetheHow tousethe Command evente216imagebuttonsargument of an image button controlHow to work with text216218220boxes, labels, check boxes,222and radio buttonsHow to work with text boxes and labels222How to work with check boxes and radio buttons224C# code for226workingwith these controls

ExpandedcontentsHow to work with list controls228Basic skills forworking with list boxes and drop-down listsforPropertiesworking with list boxes, drop-down lists, and list itemsProperties and methods for working with list item collections228How tothe Listltem Collection Editor234How to work with radio button lists and check box lists236How to work with bulleted lists and numbered lists238useHow toChapter7useother web230232controlsserver240How to get the information you need for using a control240How tousethe image control242How tousetheHow tousethe file244How tousethe246How tousethe calendar controlHow tocontrol242hyperlinkupload controlimage map controluse248the validation controlsAn introduction to the validation controlsHow touseCommon validatorHow254properties256ASP.NET processes validationHow touseHow touseHow touseHow touseHow touseHow touseHow toHow to262,techniquesthe advanced validation controlsregular expression validatorown regular expressionsuse a customvalidator266268270270272274A validation routine that validates credit card numbersChapter 8264266the validation summary controlvalidation groupsthe260260How to create yourHow to258required field validatorthe compare validatorthe range validatoruseusecontrolsthe basic validation controlstheValidation254the validation controls276How to manage stateHow touseview state282How to work with view stateHow touse282view state for yourowndataHow to use session state286How to work with session stateWhen toOptionssaveforand retrieve sessionstoring session286stateitemsstate dataOptions for tracking session IDsHowapplicationapplication288290290How to set session state optionsHow to use284292state294state works294How to work withapplicationstate dataHow to work withapplicationeventsHow to use cookies and URLencoding296298300How to create cookies300How to work with cookies302How to enable or disable cookies304How to use URL306encodingix

XExpandedcontentsChapter 9How tousemaster pagesHow to create master pages312An introduction to master pages312How to create a master page314The aspx code for316anew master pageThe aspx code for the Halloween Store masterpageThe code-behind file for the master318320pageHow to create and develop content pagesHow to createa contentHow to add content to322322page324apageThe aspx code for the Order content page326How to nest master pagesHow to create nestedHowaddtomaster328328pagescontent to a child master328pageHow to access master page controls from a content pageHow to expose a master page control as a public propertyHow toChapter10access apublic propertyHow to use siteof themaster page from a content330330332pagenavigationAn introduction to sitenavigationnavigation controlsHow to create a web. sitemap fileThe web.sitemap file for the Navigation application338How to344An introduction to theHow touseusethe site340342navigation controlsthe TreeView controlHow to createaSiteMapDataSource344control346How tousethe Menu control348How tousethe350A master pageChapter 11338How toSiteMapPath controlfor the Navigation applicationuse352themesAn introduction to themes358A page before and after a theme has been appliedHow themes workHow tocreate themesuse362skins362Another way to store skins364How to use customization themesHow366toapplyacustomization theme toanHow toapplyacustomization theme toaHow toapplyaskin toHow toremove acustomization theme fromanHow toremove acustomization theme fromapageHow toremove acustomization theme fromacontrolHow toHow toHow toaapplication366366pagecontrolstyle sheet themesapply a style sheet themeremove a style sheet themeuse360360How to work with skinsHow to create and358— 366application368368368370370370

ExpandedcontentsSection 3 ASP.NET database programmingChapter 12An introduction to databaseprogrammingAn introduction to relational databasesHowtable is378organized378How the tables in a database are related380How the columns in382TheadesignHow totabledefinedare384SQL to work with the data inuseHow to queryHow toaof the Halloween databasea relationaldatabasesingle tablea386join data from two ortablesmoreHow to add, update, and delete data in388.-.tablea390An introduction to ADO.NET 4392How the basic ADO.NET components workConcurrency and the disconnected data architecture392How396with data without usingto workadata394adapterAn introduction to the ADO.NET 4 classes13398TheSqlConnection classTheSqlCommand class398The SqlParameter class400The400TheChapter386398SqlDataReader classSqlDataAdapter classHow to useHow to create400SQL datasourcesa SQL data source404A Product Listapplication that uses two SQL datacreate a SqlDataSource controlHow toHow to define the connectionsources406'.How tosave the connectionstringHowtoconfigure the SelectstatementHowto create ain the408web.config file410412Where clause414How select parameters workHow to416use custom statements and storedproceduresHow to enter custom statementsHow to select storedHow to create418Query Builder420How to define the parametersHowto use422the DataList control424How the DataList control worksHow to define theHow to formatHow touseHow to bindHowTheHow toto430to a data sourcecontrols inadatasourcechange the datause caching430templateList applicationuse the advanceda426428aspx file for the ProductHow todata listbindinglist controlto bind the424adata listdataaHow to createHowafortemplates418418proceduresSelect statement with thea404features ofthatsourcecanupdatemodea432434SQL datathe databasesource436436438438Xi

ExpandedcontentsChapter 14How tothe GridView controluseHow to customize the GridView controlHow theGridView control worksHow to define the fields inaElements usedto create andHow to enablesortingHow to enablepagingGridView controlformat fieldsHow to customize pagingA listapplication that usesapplicationGridView controlaThe Product ListThe aspx fileHow to.updateGridView dataHow to work with command fieldsHow to use events raisedHow to insert ainrowathe GridView controlbyGridView controlA maintenance application thatTheCategoryMaintenanceuses aGridView controlapplicationThe aspx fileThe code-behind fileHow to work withHow to createtemplatetemplatefieldsfieldsThe template version of the Category MaintenanceapplicationThe aspx code for the template versionChapter 15How toHow touseuse thethe DetailsView and FormView controlsDetailsView control484An introduction to the DetailsView controlAttributes and child elements for the DetailsView controlHow to define the fields inHow to enableHow to createaDetailsView controlpagingaMaster/DetailpageHow to update DetailsView dataAn introductiontocommand buttonsHow to add command buttonsHow touse eventsHow to createraisedtemplatebythe DetailsView controlfieldsThe Product MaintenanceTheoperationof theapplicationapplicationTheaspx fileThe code-behind fileHow to use the FormView controlAnintroductionto theFormView controlHow to work with the ItemtemplateHow to work with the Editltem and InsertltemAShopping Cart applicationThe operation of the applicationthattemplatesuses aThe aspx file for the Order pageThe code-behind file for the Order pageFormView control

Expanded contentsChapter16How toHow tothe ListView anduseDataPager controlsthe ListView controluse524An introduction to the ListView control524How to526configureaListView controlHow to work with theHow to work with the ItemHowfor530template532sortingprovideprovide for pagingcustomize pagingtoHow toHow toA list528Layout template534536that usesapplicationapplicationaListView control538The Product List538The aspx fileHow540ListView datato groupHow to define the544A Product List546templates for a groupapplication that uses groupsfor the grouped Product List applicationThe aspx fileHow toHow toupdatebuttons touse546ListView data550550perform update operationstemplatesHow to work with the Editltem and Insertltem552How to use events raised552A maintenanceTheChapter 17544applicationMaintenanceCategorythe ListView controlbythat usesaListView control554554applicationThe aspx file556The code-behind file556How touseobject dataAn introduction toobjectsourcesdata sources.566How 3-layer applications work in ASP.NET566How touse568How toconfiguretheObjectDataSource controlanObjectDataSourcecontrol570How to work with bound controlsA Product List570572applicationThe aspx file574The ProductDB class576578How to create a data access classHow todesigndataaaccessclassHow to createaHow to createupdate, delete,How toAuseattributes to markCategory578select methodMaintenance580and insert methodsadataaccess582class584586applicationThe design586The aspx fileThe code-behind file586The592TheCategoryCategoryDBHow to590classuseHow to createclasspagingan594withobjectdataHow to create a data access class that598sourcesObjectDataSource controlthatprovidesprovides for pagingforpaging598600XMi

ExpandedcontentsSection 4Professional ASP.NET skillsChapter 18How to secureaweb siteAn introduction to SSL608Howsecureconnections work608Howdigitalsecurecertificates workHow to determine ifHow toHowtoHowtodigitalaand usegetasecuredigital610certificate is installedsecureonyourcertificateget a digital secure certificatework with certificates using IIS 7How to work with certificatesHow tousing earlier610612612614versions of IIS616use a secure connection618How to request a secure connectionHow to force a page to use a secure connection618A Halloween Store622Theoperation of theapplicationChapter 19 Howthat uses SSLHalloween StoreThe code for the Halloween Storeapplicationapplication620622622to authenticate and authorize usersAn introduction to authentication628Three types of authentication628How forms-based authentication works630How to set up authentication and authorization632How to start the Web Site Administration Tool632How to enable forms-based authentication634How to create and manage roles636How to create and manage usersHowto createHowtoand manageHow touseHow touse theHow tousetheto usetheuserulesrole640providercontrolsloginLogin controlthe LoginStatus and LoginNameuseHow to638accessmembership anduse theHow toHowthemodifyHow to644controls646CreateUserWizard control648PasswordRecovery control650ChangePassword controlthe Login View controlThe pagesThe directory642644theThe AuthenticationChapter 20serverapplication652654656656660structureThe access rules660The662web.configHow tofilesuseemail,custom error pages,and back-button controlHow to send emailAn introductiontoHow to installanHow to createanHow to sendHow to addanSMTP666668serveremail messageemail messageattachment toanHow to create666emailanan670672email messageHTML message674676

Expanded contentsHow touse custom errorhandlinghandlingException object forAn introduction to customHow to get and use theHow to code methods that redirect toThe code fora custom errorHow to handle HTTPerrors680errorpageHow tousetimestampsHow tousetofileproblemcachingavoid the back-button problem688690692AJAX696AJAX conceptsHow AJAX works696698How ASP.NET AJAX worksThe ASP.NET AJAXserver700700controls702The ASP.NET AJAX Control Toolkit704How to use the ASP.NET AJAX server controls706How to use theScriptManager control706How tousethe708How tousetheScriptManagerProxy controlUpdatePanel controlHow tousethe Timer controlHow tousetheAnUpdateProgress710712controlapplication that uses AJAXapplication714716The Shout Box716The Shoutltem class718The ShoutltemList class718The aspx file720The code-behind file724An introduction to726jQueryjQuery libraryThe jQuery UI libraryHow jQuery AJAX worksThe22686688An introduction to AJAXAn introduction to ASP.NET AJAXChapter682684web.configintroduction to the back-button problemHow to disable browserpageChapter 21678ana custom errorpagewith theHow to handle the back-buttonAn678error726coreHow toHow to726728configure and deploy ASP.NET 4 applicationsconfigurean ASP.NETapplication732How to use the Web Site Administration Tool732How to use the USManagement Console with Windows 7 or Windows Vista734How toManagement Console with Windows XP736useHow tothe USdeployan ASP.NETapplicationThree ways to deploy an ASP.NET applicationHow to use the Copy Web Site command for XCopydeploymentHow to use the Publish Web Site command for precompiled deploymentHow to use the aspnet compiler command for precompiled deploymentHow to create a Web Setup projectHow to create and use a Setup program738738740742744746748

XViExpanded contentsChapter23An introduction to WCF servicesBasic concepts and terms752How WCF services work752bindingsAn introduction to754How to create a WCF service756How to start756How todevelop theThe code forTheWCF serviceaalibrarycode foraWCF servicelibrarygets product informationWCF service thatconfiguration758760file for the WCF service760How to test a WCF serviceHow to createHow to startHowtoaddaWCF servicelibraryhost web siteaa764web site that hostsareferenceto a766service766libraryThe configuration files for the host web siteHow todisplayinformation about the service in768browseraHow to create a web site that consumes a WCF serviceHow to addHow toAppendix Aservice reference toaconsume a766aclient web siteWCF serviceHow to install and770772772774usethe softwareand downloadable filesHowtodownload and install the files for this book778Howtoinstall IIS under Windows 7780orWindows VistaHow to install IIS under Windows XPHowto installHow to install anduse784SQL Server 2008 Express786How to create the Halloween database788How to790Appendix B Howusethe downloaded webanIIS virtualdirectoryHow to set the default page forHow to forcetoapplications using IISWindows 7 and Windows VistaHow to createHowapplicationsto work with webunderAppendix C782Visual Studio 2010apage towork withaorapplicationweb siteuse a secureconnectionapplication pools794796798800How to work with web applications using IISunder Windows XPHow to createavirtualdirectoryHow to set the default page for a web siteHow to force a page to use a secure connection804806808

TRAINING&REFERENCE murach's webprogrammingwith C#2010 AnneBoehm JoelMurach Va. MikeMurach&Associates, Inc. IJ) 1-800-221-5528 (559)440-9071