ProASP.
NET4inC#2010FourthEditionMatthewMacDonald,AdamFreeman,andMarioSzpusztaProASP.
NETinC#2010,FourthEditionCopyright2010byMatthewMacDonald,AdamFreeman,andMarioSzpusztaAllrightsreserved.
Nopartofthisworkmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical,includingphotocopying,recording,orbyanyinformationstorageorretrievalsystem,withoutthepriorwrittenpermissionofthecopyrightthepublisher.
ISBN-13(pbk):978-1-4302-2529-4ISBN-13(electronic):978-1-4302-2530-0PrintedandboundintheUnitedStatesofAmerica987654321Trademarkednames,logos,andimagesmayappearinthisbook.
Ratherthanuseatrademarksymbolwitheveryoccurrenceofatrademarkedname,logo,orimageweusethenames,logos,andimagesonlyinaneditorialfashionandtothebenefitofthetrademarkowner,withnointentionofinfringementofthetrademark.
Theuseinthispublicationoftradenames,trademarks,servicemarks,andsimilarterms,eveniftheyarenotidentifiedassuch,isnottobetakenasanexpressionofopinionastowhetherornottheyaresubjecttoproprietaryrights.
PresidentandPublisher:PaulManningLeadEditor:EwanBuckinghamTechnicalReviewers:FabioClaudioFerracchiatiandToddMeisterEditorialBoard:ClayAndres,SteveAnglin,MarkBeckner,EwanBuckingham,GaryCornell,JonathanGennick,JonathanHassell,MichelleLowman,MatthewMoodie,DuncanParkes,JeffreyPepper,FrankPohlmann,DouglasPundick,BenRenow-Clarke,DominicShakeshaft,MattWade,TomWelshCoordinatingEditor:AnneCollettCopyEditors:RalphMoore,KatieStence,KimWimpsettCompositor:MarySudulIndexer:KevinBroccoliArtist:AprilMilneCoverDesigner:AnnaIshchenkoDistributedtothebooktradeworldwidebySpringerScience+BusinessMedia,LLC.
,233SpringStreet,6thFloor,NewYork,NY10013.
Phone1-800-SPRINGER,fax(201)348-4505,e-mailorders-ny@springer-sbm.
com,orvisitwww.
springeronline.
com.
Forinformationontranslations,pleasee-mailrights@apress.
com,orvisitwww.
apress.
com.
ApressandfriendsofEDbooksmaybepurchasedinbulkforacademic,corporate,orpromotionaluse.
eBookversionsandlicensesarealsoavailableformosttitles.
Formoreinformation,referenceourSpecialBulkSales–eBookLicensingwebpageatwww.
apress.
com/info/bulksales.
Theinformationinthisbookisdistributedonan"asis"basis,withoutwarranty.
Althougheveryprecautionhasbeentakeninthepreparationofthiswork,neithertheauthor(s)norApressshallhaveanyliabilitytoanypersonorentitywithrespecttoanylossordamagecausedorallegedtobecauseddirectlyorindirectlybytheinformationcontainedinthiswork.
Thesourcecodeforthisbookisavailabletoreadersatwww.
apress.
com.
Youwillneedtoanswerquestionspertainingtothisbookinordertosuccessfullydownloadthecode.
iiiContentsataGlanceContents.
vAbouttheAuthorxxxiiAbouttheTechnicalReviewer.
xxxiiiIntroduction.
xxxivPart1:CoreConcepts.
1Chapter1:IntroducingASP.
NET.
3Chapter2:VisualStudio.
21Chapter3:WebForms.
77Chapter4:ServerControls.
129Chapter5:ASP.
NETApplications183Chapter6:StateManagement235Part2:DataAccess275Chapter7:ADO.
NETFundamentals277Chapter8:DataComponentsandtheDataSet.
321Chapter9:DataBinding.
353Chapter10:RichDataControls.
403Chapter11:CachingandAsynchronousPages477Chapter12:FilesandStreams.
527Chapter13:LINQ563Chapter14:XML.
617ivPart3:BuildingASP.
NETWebsites.
679Chapter15:UserControls.
681Chapter16:ThemesandMasterPages703Chapter17:WebsiteNavigation.
735Chapter18:WebsiteDeployment.
791Part4:Security.
833Chapter19:TheASP.
NETSecurityModel835Chapter20:FormsAuthentication.
851Chapter21:Membership.
877Chapter22:WindowsAuthentication.
933Chapter23:AuthorizationandRoles963Chapter24:Profiles995Chapter25:Cryptography.
1029Chapter26:CustomMembershipProviders1061Part5:AdvancedUserInterface.
1099Chapter27:CustomServerControls.
1101Chapter28:Graphics,GDI+,andCharting1135Chapter29:JavaScriptandAjaxTechniques1179Chapter30:ASP.
NETAJAX.
1239Chapter31:PortalswithWebPartPages.
1303Chapter32:MVC1363Chapter33:DynamicData1397Chapter34:Silverlight.
1437Index.
1491CONTENTSvContentsContentsataGlance.
iiiAbouttheAuthorxxxiiAbouttheTechnicalReviewer.
xxxiiiIntroduction.
xxxivPart1:CoreConcepts.
1Chapter1:IntroducingASP.
NET.
3TheSevenPillarsofASP.
NET3#1:ASP.
NETIsIntegratedwiththe.
NETFramework3#2:ASP.
NETIsCompiled,NotInterpreted.
4#3:ASP.
NETIsMultilanguage6#4:ASP.
NETIsHostedbytheCommonLanguageRuntime.
8#5:ASP.
NETIsObject-Oriented.
9#6:ASP.
NETSupportsallBrowsers.
11#7:ASP.
NETIsEasytoDeployandConfigure11TheEvolutionofASP.
NET12ASP.
NET1.
0and1.
1.
12ASP.
NET2.
0.
12ASP.
NET3.
5.
13ASP.
NET4.
16Silverlight18Summary19CONTENTSviChapter2:VisualStudio.
21IntroducingVisualStudio.
21WebsitesandWebProjects.
22CreatingaProjectlessWebsite.
23DesigningaWebPage.
28TheVisualStudioIDE.
35SolutionExplorer37DocumentWindow38Toolbox.
38ErrorListandTaskList.
39ServerExplorer.
41TheCodeEditor42AddingAssemblyReferences.
43IntelliSenseandOutlining.
46VisualStudio2010Improvements.
50TheCodeModel.
56HowCode-BehindFilesAreConnectedtoPages59HowControlTagsAreConnectedtoPageVariables60HowEventsAreConnectedtoEventHandlers61WebProjects.
63CreatingaWebProject.
64MigratingaWebsitefromaPreviousVersionofVisualStudio.
66VisualStudioDebugging.
68Single-StepDebugging.
69VariableWatches.
72AdvancedBreakpoints.
74TheWebDevelopmentHelper74Summary76Chapter3:WebForms.
77PageProcessing78HTMLForms78CONTENTSviiDynamicUserInterface80TheASP.
NETEventModel81AutomaticPostbacks.
82ViewState84XHTMLCompliance.
88Client-SideControlIDs94WebFormsProcessingStages.
97PageFrameworkInitialization.
98UserCodeInitialization.
99Validation.
99EventHandling.
100AutomaticDataBinding.
100Cleanup.
101APageFlowExample101ThePageAsaControlContainer104ShowingtheControlTree.
104ThePageHeader109DynamicControlCreation.
110ThePageClass112Session,Application,andCache112Request113Response.
114Server.
118User121Trace.
121AccessingtheHTTPContextinAnotherClass.
127Summary128Chapter4:ServerControls.
129TypesofServerControls.
129TheServerControlHierarchy130HTMLServerControls.
132TheHtmlControlClass133CONTENTSviiiTheHtmlContainerControlClass.
133TheHtmlInputControlClass.
134TheHTMLServerControlClasses134SettingStyleAttributesandOtherProperties.
136ProgrammaticallyCreatingServerControls137HandlingServer-SideEvents.
139WebControls142TheWebControlBaseClass.
143BasicWebControlClasses.
145Units147Enumerations147Colors148Fonts.
148Focus.
150TheDefaultButton.
151ScrollablePanels.
152HandlingWebControlEvents153TheListControls.
156TheSelectableListControls.
157TheBulletedListControl161InputValidationControls.
162TheValidationControls.
163TheValidationProcess164TheBaseValidatorClass.
165TheRequiredFieldValidatorControl.
167TheRangeValidatorControl.
167TheCompareValidatorControl.
168TheRegularExpressionValidatorControl168TheCustomValidatorControl.
171TheValidationSummaryControl172UsingtheValidatorsProgrammatically174ValidationGroups.
175CONTENTSixRichControls.
177TheAdRotatorControl178TheCalendarControl.
180Summary182Chapter5:ASP.
NETApplications183AnatomyofanASP.
NETApplication.
183TheApplicationDomain.
184ApplicationLifetime.
185ApplicationUpdates.
186ApplicationDirectoryStructure186Theglobal.
asaxApplicationFile187ApplicationEvents.
189DemonstratingApplicationEvents.
191ASP.
NETConfiguration192Themachine.
configFile193Theweb.
configFile195199200201202ReadingandWritingConfigurationSectionsProgrammatically.
203TheWebsiteAdministrationTool(WAT)206ExtendingtheConfigurationFileStructure.
207EncryptingConfigurationSections211.
NETComponents213CreatingaComponent.
214UsingaComponentThroughtheApp_CodeDirectory215UsingaComponentThroughtheBinDirectory216ExtendingtheHTTPPipeline.
219HTTPHandlers.
219CreatingaCustomHTTPHandler221ConfiguringaCustomHTTPHandler222CONTENTSxUsingConfiguration-FreeHTTPHandlers.
223CreatinganAdvancedHTTPHandler.
223CreatinganHTTPHandlerforNon-HTMLContent.
226HTTPModules.
229CreatingaCustomHTTPModule.
231Summary234Chapter6:StateManagement235ASP.
NETStateManagement.
236ViewState.
238AViewStateExample.
239StoringObjectsinViewState.
241AssessingViewState243SelectivelyDisablingViewState244ViewStateSecurity246TransferringInformationBetweenPages.
247TheQueryString.
248Cross-PagePosting249Cookies.
256SessionState.
258SessionArchitecture258UsingSessionState.
259ConfiguringSessionState261SecuringSessionState268ApplicationState.
269StaticApplicationVariables.
271Summary273Part2:DataAccess275Chapter7:ADO.
NETFundamentals277TheADO.
NETArchitecture.
278ADO.
NETDataProviders.
278CONTENTSxiStandardizationinADO.
NET280FundamentalADO.
NETClasses281TheConnectionClass283ConnectionStrings283TestingaConnection.
286ConnectionPooling.
287TheCommandandDataReaderClasses.
289CommandBasics.
290TheDataReaderClass291TheExecuteReader()MethodandtheDataReader.
292TheExecuteScalar()Method.
298TheExecuteNonQuery()Method298SQLInjectionAttacks.
299UsingParameterizedCommands303CallingStoredProcedures.
304Transactions307TransactionsandASP.
NETApplications.
307IsolationLevels.
312Savepoints.
314Provider-AgnosticCode.
315CreatingtheFactory316CreateObjectswithFactory317AQuerywithProvider-AgnosticCode318Summary319Chapter8:DataComponentsandtheDataSet.
321BuildingaDataAccessComponent.
321TheDataPackage.
323TheStoredProcedures.
324TheDataUtilityClass.
325TestingtheDatabaseComponent.
331DisconnectedData.
333WebApplicationsandtheDataSet334CONTENTSxiiXMLIntegration335TheDataSet335TheDataAdapterClass337FillingaDataSet338WorkingwithMultipleTablesandRelationships.
340SearchingforSpecificRows343UsingtheDataSetinaDataAccessClass.
344DataBinding.
345TheDataViewClass345SortingwithaDataView346FilteringwithaDataView348AdvancedFilteringwithRelationships350CalculatedColumns.
350Summary352Chapter9:DataBinding.
353BasicDataBinding.
354Single-ValueBinding354OtherTypesofExpressions.
356Repeated-ValueBinding.
360DataSourceControls.
368ThePageLifeCyclewithDataBinding.
369TheSqlDataSource370SelectingRecords.
371ParameterizedCommands374HandlingErrors.
379UpdatingRecords379DeletingRecords384InsertingRecords384DisadvantagesoftheSqlDataSource385TheObjectDataSource.
386SelectingRecords.
387CONTENTSxiiiUpdatingRecords392UpdatingwithaDataObject.
393TheLimitsoftheDataSourceControls397TheProblem398AddingtheExtraItems399HandlingtheExtraOptionswiththeSqlDataSource399HandlingtheExtraOptionswiththeObjectDataSource400Summary401Chapter10:RichDataControls.
403TheGridView.
404DefiningColumns404FormattingtheGridView.
408FormattingFields.
409Styles.
410Formatting-SpecificValues414GridViewRowSelection.
416UsingSelectiontoCreateaMaster-DetailsForm.
418TheSelectedIndexChangedEvent420UsingaDataFieldAsaSelectButton421SortingtheGridView.
422SortingwiththeSqlDataSource422SortingwiththeObjectDataSource423SortingandSelection425AdvancedSorting425PagingtheGridView427AutomaticPaging427PagingandSelection.
429CustomPaginationwiththeObjectDataSource.
429CustomizingthePagerBar.
432GridViewTemplates.
433UsingMultipleTemplates.
435CONTENTSxivEditingTemplatesinVisualStudio436BindingtoaMethod437HandlingEventsinaTemplate.
439EditingwithaTemplate.
440ClientIDsinTemplates.
447TheListView447Grouping.
451Paging.
453TheDetailsViewandFormView454TheDetailsView.
454TheFormView.
457AdvancedGrids.
459SummariesintheGridView459AParent/ChildViewinaSingleTable461EditingaFieldUsingaLookupTable.
464ServingImagesfromaDatabase466DetectingConcurrencyConflicts472Summary476Chapter11:CachingandAsynchronousPages477UnderstandingASP.
NETCaching.
477OutputCaching478DeclarativeOutputCaching.
479CachingandtheQueryString.
480CachingwithSpecificQueryStringParameters.
481CustomCachingControl.
481CachingwiththeHttpCachePolicyClass.
483Post-CacheSubstitutionandFragmentCaching.
484CacheProfiles.
487CacheConfiguration487OutputCachingExtensibility.
488DataCaching493AddingItemstotheCache494CONTENTSxvASimpleCacheTest.
496CachePriorities498CachingwiththeDataSourceControls.
498CacheDependencies502FileandCacheItemDependencies502AggregateDependencies503TheItemRemovedCallback.
504UnderstandingSQLCacheNotifications.
507HowCacheNotificationsWork508EnablingNotifications.
508CreatingtheCacheDependency509CustomCacheDependencies.
510ABasicCustomCacheDependency.
510ACustomCacheDependencyUsingMessageQueues512AsynchronousPages514CreatinganAsynchronousPage.
515QueryingDatainanAsynchronousPage.
517HandlingErrors.
519UsingCachingwithAsynchronousTasks.
522MultipleAsynchronousTasksandTimeouts524Summary526Chapter12:FilesandStreams.
527WorkingwiththeFileSystem.
527TheDirectoryandFileClasses528TheDirectoryInfoandFileInfoClasses530TheDriveInfoClass.
533WorkingwithAttributes.
534FilterFileswithWildcards536RetrievingFileVersionInformation537ThePathClass.
538AFileBrowser541CONTENTSxviReadingandWritingFileswithStreams.
546TextFiles547BinaryFiles.
549UploadingFiles.
550MakingFilesSafeforMultipleUsers.
552Compression.
557Serialization.
558Summary561Chapter13:LINQ563LINQBasics.
563DeferredExecution.
565HowLINQWorks.
566LINQExpressions.
567LINQExpressions"UndertheHood"575LINQtoDataSet.
578TypedDataSets581NullValues.
581LINQtoEntities581GeneratingtheDataModel.
582TheDataModelClasses583EntityRelationships.
586QueryingStoredProcedures.
587LINQtoEntitiesQueries"UndertheHood"589DatabaseOperations595Inserts.
595Updates598Deletes.
598ManagingConcurrency.
598HandlingConcurrencyConflicts599TheEntityDataSourceControl.
604DisplayingData.
604CONTENTSxviiGettingRelatedData.
609EditingData610Validation.
611UsingtheQueryExtenderControl.
612UsingaSearchExpression.
613UsingaRangeExpression614UsingaPropertyExpression.
614UsingaMethodExpression615Summary616Chapter14:XML.
617WhenDoesUsingXMLMakeSense617AnIntroductiontoXML618TheAdvantagesofXML.
619Well-FormedXML.
620XMLNamespaces.
621XMLSchemas.
622Stream-BasedXMLProcessing624WritingXMLFiles.
624ReadingXMLFiles.
628In-MemoryXMLProcessing.
631TheXmlDocument632TheXPathNavigator.
636TheXDocument638SearchingXMLContent643SearchingwithXmlDocument.
644SearchingXmlDocumentwithXPath.
646SearchingXDocumentwithLINQ.
649ValidatingXMLContent.
651ABasicSchema.
651ValidatingwithXmlDocument652ValidatingwithXDocument654CONTENTSxviiiTransformingXMLContent.
654ABasicStylesheet.
655UsingXslCompiledTransform656UsingtheXmlControl.
657TransformingXMLwithLINQtoXML.
658XMLDataBinding660NonhierarchicalBinding660UsingXPath662NestedGrids.
665HierarchicalBindingwiththeTreeView667UsingXSLT.
669BindingtoXMLContentfromOtherSources.
671UpdatingXMLThroughtheXmlDataSource672XMLandtheADO.
NETDataSet.
672ConvertingtheDataSettoXML.
673AccessingaDataSetAsXML.
675Summary678Part3:BuildingASP.
NETWebsites.
679Chapter15:UserControls.
681UserControlBasics681CreatingaSimpleUserControl682ConvertingaPagetoaUserControl.
684AddingCodetoaUserControl.
684HandlingEvents.
684AddingProperties.
685UsingCustomObjects688AddingEvents.
690ExposingtheInnerWebControl694DynamicallyLoadingUserControls695PortalFrameworks695CONTENTSxixPartialPageCaching.
699VaryByControl.
699SharingCachedControls701Summary702Chapter16:ThemesandMasterPages703CascadingStyleSheets703CreatingaStylesheet703ApplyingStylesheetRules.
706Themes.
709ThemeFoldersandSkins709ApplyingaSimpleTheme.
711HandlingThemeConflicts.
712CreatingMultipleSkinsfortheSameControl713SkinswithTemplatesandImages.
714UsingCSSinaTheme717ApplyingThemesThroughaConfigurationFile.
717ApplyingThemesDynamically.
718StandardizingWebsiteLayout720MasterPageBasics.
720ASimpleMasterPage721ASimpleContentPage.
723DefaultContent.
725MasterPageswithTablesandCSSLayout726MasterPagesandRelativePaths.
729ApplyingMasterPagesThroughaConfigurationFile.
730AdvancedMasterPages730InteractingwiththeMasterPageClass.
730DynamicallySettingaMasterPage.
732NestingMasterPages732Summary734CONTENTSxxChapter17:WebsiteNavigation.
735PageswithMultipleViews.
736TheMultiViewControl736TheWizardControl741SiteMaps.
751DefiningaSiteMap752BindingtoaSiteMap753Breadcrumbs.
754ShowingaPortionoftheSiteMap.
757TheSiteMapObjects.
760AddingCustomSiteMapInformation.
762CreatingaCustomSiteMapProvider.
763SecurityTrimming770URLMappingandRouting772URLMapping772URLRouting.
773TheTreeViewControl.
774TheTreeNode775PopulatingNodesonDemand778TreeViewStyles.
779TheMenuControl783MenuStyles.
786MenuTemplates.
788Summary789Chapter18:WebsiteDeployment.
791InstallingandConfiguringIIS.
791InstallingIIS7.
791ManagingIIS7.
793DeployingaWebsite.
795DeployingbyCopyingFiles.
796UsingWebDeployment801CONTENTSxxiUsingFTPDeployment.
809ManagingaWebsite.
817CreatingaNewSite.
817CreatingVirtualDirectories818UsingtheVirtualPathProvider.
819UsingApplicationPools823UsingApplicationWarm-Up.
826ExtendingtheIntegratedPipeline.
828CreatingtheHandler.
828DeployingtheHandler829ConfiguringtheHandler.
829TestingtheHandler830Summary831Part4:Security.
833Chapter19:TheASP.
NETSecurityModel835WhatItMeanstoCreateSecureSoftware.
835UnderstandingPotentialThreats835SecureCodingGuidelines.
836UnderstandingGatekeepers837UnderstandingtheLevelsofSecurity.
838Authentication838Authorization839ConfidentialityandIntegrity840PullingItAllTogether841UnderstandingSecureSocketsLayer.
842UnderstandingCertificates.
843UnderstandingSSL.
843ConfiguringSSLinIIS7.
x845Summary849CONTENTSxxiiChapter20:FormsAuthentication.
851IntroducingFormsAuthentication851WhyUseFormsAuthentication852WhyWouldYouNotUseFormsAuthentication854WhyNotImplementCookieAuthenticationYourself855TheFormsAuthenticationClasses856ImplementingFormsAuthentication.
857ConfiguringFormsAuthentication.
857DenyingAccesstoAnonymousUsers861CreatingaCustomLoginPage862CustomCredentialsStore.
868PersistentCookiesinFormsAuthentication.
869IIS7.
xandFormsAuthentication.
871Summary876Chapter21:Membership.
877IntroducingtheASP.
NETMembershipAPI.
877UsingtheMembershipAPI880ConfiguringFormsAuthentication.
882CreatingtheDataStore883ConfiguringConnectionStringandMembershipProvider890CreatingandAuthenticatingUsers.
893UsingtheSecurityControls897TheLoginControl.
898TheLoginStatusControl909TheLoginViewControl.
910ThePasswordRecoveryControl.
911TheChangePasswordControl.
916TheCreateUserWizardControl.
917ConfiguringMembershipinIIS7.
x.
922ConfiguringProvidersandUsers.
922UsingtheMembershipAPIwithOtherApplications.
924CONTENTSxxiiiUsingtheMembershipClass.
926RetrievingUsersfromtheStore927UpdatingUsersintheStore.
929CreatingandDeletingUsers.
930ValidatingUsers.
931Summary931Chapter22:WindowsAuthentication.
933IntroducingWindowsAuthentication.
933WhyUseWindowsAuthentication933WhyWouldYouNotUseWindowsAuthentication935MechanismsforWindowsAuthentication935ImplementingWindowsAuthentication.
942ConfiguringIIS7.
x942ConfiguringASP.
NET944DeeperIntotheIIS7.
xPipeline945DenyingAccesstoAnonymousUsers948AccessingWindowsUserInformation.
950Impersonation.
956ImpersonationandDelegationinWindows956ConfiguredImpersonation958ProgrammaticImpersonation.
959Summary962Chapter23:AuthorizationandRoles963URLAuthorization963AuthorizationRules964FileAuthorization.
970AuthorizationChecksinCode.
970UsingtheIsInRole()Method.
970UsingthePrincipalPermissionClass971UsingtheRolesAPIforRole-BasedAuthorization.
974UsingtheLoginViewControlwithRoles.
981CONTENTSxxivAccessingRolesProgrammatically981UsingtheRolesAPIwithWindowsAuthentication.
984AuthorizationandRolesinIIS7.
x.
986AuthorizationwithASP.
NETRolesinIIS7.
x989ManagingASP.
NETRoleswithIIS7.
x991Summary993Chapter24:Profiles995UnderstandingProfiles995ProfilePerformance.
996HowProfilesStoreData.
997ProfilesandAuthentication998Profilesvs.
CustomDataComponents998UsingtheSqlProfileProvider.
998CreatingtheProfileTables999ConfiguringtheProvider.
1002DefiningProfileProperties.
1003UsingProfileProperties.
1004ProfileSerialization1006ProfileGroups.
1008ProfilesandCustomDataTypes.
1008TheProfilesAPI1012AnonymousProfiles.
1015CustomProfileProviders1017TheCustomProfileProviderClasses.
1018DesigningtheFactoredProfileProvider.
1020CodingtheFactoredProfileProvider.
1021TestingtheFactoredProfileProvider1025Summary1028Chapter25:Cryptography.
1029EncryptingData:ConfidentialityMatters.
1029The.
NETCryptographyNamespace1030CONTENTSxxvUnderstandingthe.
NETCryptographyClasses1033SymmetricEncryptionAlgorithms.
1035AsymmetricEncryption1036TheAbstractEncryptionClasses.
1037TheICryptoTransformInterface.
1037TheCryptoStreamClass1038EncryptingSensitiveData.
1039ManagingSecrets.
1039UsingSymmetricAlgorithms.
1041UsingAsymmetricAlgorithms1047EncryptingSensitiveDatainaDatabase.
1049EncryptingtheQueryString.
1054WrappingtheQueryString1054CreatingaTestPage1057Summary1059Chapter26:CustomMembershipProviders1061ArchitectureofCustomProviders.
1061BasicStepsforCreatingCustomProviders.
1063OverallDesignoftheCustomProvider.
1063DesigningandImplementingtheCustomStore.
1065ImplementingtheProviderClasses.
1072UsingtheCustomProviderClasses.
1092Summary1097Part5:AdvancedUserInterface.
1099Chapter27:CustomServerControls.
1101CustomServerControlBasics1101CreatingaBare-BonesCustomControl.
1102UsingaCustomControl.
1104CustomControlsintheToolbox.
1105CreatingaWebControlThatSupportsStyleProperties.
1108CONTENTSxxviTheRenderingProcess.
1111DealingwithDifferentBrowsers.
1113TheHtmlTextWriter.
1113BrowserDetection.
1114BrowserProperties.
1115OverridingBrowserTypeDetection.
1117AdaptiveRendering1117ControlStateandEvents1119ViewState1119ControlState.
1121PostbackDataandChangeEvents.
1123TriggeringaPostback.
1125ExtendingExistingWebControls.
1127CompositeControls1127DerivedControls1130Summary1133Chapter28:Graphics,GDI+,andCharting1135TheImageMapControl.
1135CreatingHotspots.
1136HandlingHotspotClicks.
1137ACustomHotspot.
1139DrawingwithGDI+1141SimpleDrawing1141ImageFormatandQuality1143TheGraphicsClass.
1145UsingaGraphicsPath1148Pens.
1149Brushes1152EmbeddingDynamicGraphicsinaWebPage.
1154UsingthePNGFormat1155PassingInformationtoDynamicImages.
1155CustomControlsThatUseGDI+1158CONTENTSxxviiUsingtheChartControl.
1163CreatingaBasicChart.
1163PopulatingaChartwithData.
1170Summary1178Chapter29:JavaScriptandAjaxTechniques1179JavaScriptEssentials.
1179TheHTMLDocumentObjectModel1180Client-SideEvents1181ScriptBlocks1184ManipulatingHTMLElements.
1185DebuggingJavaScript1186BasicJavaScriptExamples.
1189CreatingaJavaScriptPageProcessor1190UsingJavaScripttoDownloadImagesAsynchronously.
1193RenderingScriptBlocks1198ScriptInjectionAttacks.
1199RequestValidation.
1200DisablingRequestValidation.
1201ExtendingRequestValidation.
1203CustomControlswithJavaScript.
1205Pop-UpWindows1205RolloverButtons1210Frames.
1213FrameNavigation1214InlineFrames.
1216UnderstandingAjax.
1217TheXMLHttpRequestObject.
1218AnAjaxExample.
1220UsingAjaxwithClientCallbacks1224CreatingaClientCallback1225ClientCallbacks"UndertheHood"1231CONTENTSxxviiiClientCallbacksinCustomControls.
1232Summary1237Chapter30:ASP.
NETAJAX.
1239IntroducingASP.
NETAJAX.
1239ASP.
NETAJAXontheClient:TheScriptLibraries1240ASP.
NETAJAXontheServer:TheScriptManager.
1241ServerCallbacks.
1242WebServicesinASP.
NETAJAX.
1243PlacingaWebMethodinaPage.
1250ASP.
NETAJAXApplicationServices.
1252ASP.
NETAJAXServerControls.
1259PartialRenderingwiththeUpdatePanel.
1260TimedRefresheswiththeTimer1268Time-ConsumingUpdateswithUpdateProgress.
1269ManagingBrowserHistory1272DeeperintotheClientLibraries.
1276UnderstandingtheClientModel1276Object-OrientedProgramminginJavaScript.
1277TheWeb-PageFramework.
1286ControlExtenders1291InstallingtheASP.
NETAJAXControlToolkit.
1292TheAutoCompleteExtender1294TheASP.
NETAJAXControlToolkit1297Summary1302Chapter31:PortalswithWebPartPages.
1303TypicalPortalPages1304BasicWebPartPages.
1305CreatingthePageDesign.
1306WebPartManagerandWebPartZoneControls1307AddingWebPartstothePage.
1309CustomizingthePage.
1313CONTENTSxxixCreatingWebParts.
1316SimpleWebPartTasks.
1316DevelopingAdvancedWebParts.
1325WebPartEditors.
1335ConnectingWebParts1341CustomVerbsandWebParts1350UserControlsandAdvancedWebParts1351UploadingWebPartsDynamically.
1354AuthorizingWebParts1360FinalTasksforPersonalization.
1360Summary1361Chapter32:MVC1363ChoosingBetweenMVCandWebForms.
1363CreatingaBasicMVCApplication.
1364CreatingtheModel1365CreatingtheController1365CreatingtheIndexView.
1366Testingthe(Incomplete)Application.
1367CompletingtheControllerandViews1368ModifyingtheSite.
MasterFile.
1371ExtendingtheBasicMVCApplication.
1371ConfiguringRouting.
1371AddingErrorHandling1373AddingAuthentication1374ConsolidatingDataStoreAccess.
1375AddingSupportforForeignKeyConstraints1378CustomizingViews.
1378ModifyingtheView.
1379AddingViewData1381AddingtotheModel.
1383CONTENTSxxxValidatingData.
1388PerformingBasicValidation1388AddingValidationAnnotations.
1390UsingActionResults.
1393ReturningJSONData.
1394CallingAnotherControllerMethod.
1395Summary1396Chapter33:DynamicData1397CreatingaDynamicDataApplication1397CreatingtheDynamicDataSite.
1397ExploringtheDynamicDataSite1400UnderstandingtheAnatomyofaDynamicDataProject.
1403CustomizingaDynamicDataSite.
1404CustomizingwithTemplates1404CustomizingwithRoutes.
1414CustomizingwithMetadata.
1423CustomizingValidation1430Summary1435Chapter34:Silverlight.
1437UnderstandingSilverlight1438Silverlightvs.
Flash1439SilverlightSystemRequirements1441CreatingaSilverlightSolution1442SilverlightCompilation1443TheEntryPage1445CreatingaSilverlightProject.
1449DesigningaSilverlightPage.
1450UnderstandingXAML1454SettingProperties.
1455TheXAMLCode-Behind.
1456HandlingEvents.
1457CONTENTSxxxiBrowsingtheSilverlightClassLibraries.
1459Layout.
1460TheCanvas.
1460TheGrid1466Animation.
1471AnimationBasics.
1471DefininganAnimation1472TheStoryboardClass.
1472AnInteractiveAnimationExample.
1475Transforms1479UsingWebServiceswithSilverlight.
1483CreatingtheWebService.
1484AddingaWebReference1484CallingtheWebService.
1485ConfiguringtheWebServiceURL.
1487Cross-DomainWebServiceCalls1488Summary1489Index.
1491CONTENTSxxxiiAbouttheAuthorsMatthewMacDonaldisanauthor,educator,andMicrosoftMVP.
He'stheauthorofmorethanadozenbooksabout.
NETprogramming,includingProSilverlight3inC#(Apress,2009),ProWPFinC#2010(Apress,2010),andBeginningASP.
NET4inC#2010(Apress,2010).
HelivesinTorontowithhiswifeandtwodaughters.
AdamFreemanisanexperiencedITprofessionalwhohasheldseniorpositionsinarangeofcompanies,mostrecentlychieftechnologyofficerandchiefoperatingofficerofaglobalbank.
HehaswrittenseveralofbooksonJavaand.
NETandhasalong-terminterestinallthingsparallel.
MarioSzpusztaworksasanarchitectintheDeveloperandPlatformgroupofMicrosoftAustriaandhelpssoftwarearchitectsoftopenterpriseandwebcustomerswithestablishingnewMicrosofttechnologies.
Forseveralyearshehasbeenfocusingonsecuresoftwaredevelopment,webservicesandinteroperability,andtheintegrationofMicrosoftOfficeclientsandserversincustomapplications.
MariospeaksregularlyatlocalandinternationalconferencessuchasDevDaysandTechEdEuropeDevelopers,andhehasbeenatechnicalcontentownerofTechEdEuropeDevelopersinthepasttwoyears.
CONTENTSxxxiiiAbouttheTechnicalReviewersFabioClaudioFerracchiatiisaprolificwriteroncutting-edgetechnologies.
Fabiohascontributedtomorethanadozenbookson.
NET,C#,VisualBasic,andASP.
NET.
Heisa.
NETMicrosoftCertifiedSolutionDeveloper(MCSD)andlivesinRome,Italy.
Youcanreadhisblogathttp://www.
ferracchiati.
com.
ToddMeisterhasbeenusingMicrosofttechnologiesformorethantenyears.
He'sbeenatechnicaleditoronmorethan50booksontopicsrangingfromSQLServertothe.
NETFramework.
Besidestechnicalediting,heisanassistantdirectorforcomputingservicesatBallStateUniversityinMuncie,Indiana.
HelivesincentralIndianawithhiswife,Kimberly,andtheirfouroutstandingchildren.
INTRODUCTIONxxxivIntroductionWhen.
NETfirstappeared,itintroducedasmallavalancheofnewtechnologies.
Therewasawholenewwaytowritewebapplications(ASP.
NET),awholenewwaytoconnecttodatabases(ADO.
NET),newtypesafelanguages(C#andVB.
NET),andamanagedruntime(theCLR).
NotleastamongthesenewtechnologieswasWindowsForms,alibraryofclassesforbuildingWindowsapplications.
Asyounodoubtalreadyknow,ASP.
NETisMicrosoft'snext-generationtechnologyforcreatingserver-sidewebapplications.
It'sbuiltontheMicrosoft.
NETFramework,whichisaclusterofcloselyrelatedtechnologiesthatrevolutionizeeverythingfromdatabaseaccesstodistributedapplications.
ASP.
NETisoneofthemostimportantcomponentsofthe.
NETFramework—it'sthepartthatenablesyoutodevelophigh-performancewebapplications.
It'snothardtogetdevelopersinterestedinASP.
NET.
Withoutexaggeration,ASP.
NETisthemostcompleteplatformforwebdevelopmentthat'severbeenputtogether.
Itfaroutclassesitspredecessor,ASP,whichwasdesignedasaquick-and-dirtysetoftoolsforinsertingdynamiccontentintoordinarywebpages.
Bycontrast,ASP.
NETisafull-blownplatformfordevelopingcomprehensive,blisteringlyfastwebapplications.
Inthisbook,you'lllearneverythingyouneedtomasterASP.
NET4.
Ifyou'veprogrammedwithapreviousversionofASP.
NET,youcanfocusonnewfeaturessuchasASP.
NETMVC(Chapter32),ASP.
NETDynamicData(Chapter33),andSilverlight(Chapter34).
Ifyou'veneverprogrammedwithASP.
NET,you'llfindthatthisbookprovidesawell-pacedtourthatleadsyouthroughallthefundamentals,alongwithabackstagepassthatletsyouseehowtheASP.
NETinternalsreallywork.
TheonlyrequirementforthisbookisthatyouhaveasolidunderstandingoftheC#languageandthebasicsof.
NET.
Ifyou'reaseasonedJavaorC++developerbutyou'renewtoC#,youmayfinditeasiertostartwithabookabout.
NETfundamentals,suchasProC#2010andthe.
NET4PlatformbyAndrewTroelsen(Apress,2010).
WhatDoesThisBookCoverHereisaquickbreakdownofwhatyou'llfindinthisbook:Part1:CoreConcepts:You'llbegininChapter1withalookattheoverallASP.
NETplatform,the.
NETFramework,andanoverviewofthechangesthathavetakenplaceinASP.
NET4.
InChapter2you'llbranchouttolearnthetoolsofthetrade—namely,VisualStudio2008.
InChapters3,4,5,and6you'lllearnthekeypartsoftheASP.
NETinfrastructure,suchastheweb-pagemodel,applicationconfiguration,andstatemanagement.
Asyoulearnthesecoreconcepts,you'llalsotakealow-levellookathowASP.
NETprocessesrequestsandmanagesthelifetimeofyourwebapplications.
You'llevenlearnhowtoextendtheASP.
NETarchitecture.
Part2:DataAccess:Thisparttacklesoneofthecoreproblemdomainsforallsoftwaredevelopment—accessingandmanipulatingdata.
InChapters7and8you'llconsiderthefundamentalsofADO.
NETastheyapplytowebapplicationsandlearnhowtodesigndataaccesscomponents.
InChapters9and10you'lllearnaboutASP.
NET'ssetofinnovativedata-boundcontrolsthatletyouformatandpresentdatawithoutwritingpagesofcode.
Chapter11branchesINTRODUCTIONxxxvoutintoadvancedcachingstrategiesthatensurefirst-classperformance.
Finally,Chapters12,13,and14movebeyondtheworldofADO.
NETtoshowyouhowtoworkwithfiles,LINQ,andXMLcontent.
Part3:BuildingASP.
NETWebsites:Inthispartyou'lllearnaboutessentialtechniquesandfeaturesformanaginggroupsofwebpages.
You'llstartsimplywithusercontrolsinChapter15,whichallowyoutoreusesegmentsoftheuserinterface.
InChapter16you'llconsiderthemes(forstylingcontrolsautomatically)andmasterpages(forreusingalayouttemplateacrossmultiplepages).
Chapter17showshowyoucanuseASP.
NET'snavigationmodeltoletvisitorssurffromonepagetoanother.
Finally,Chapter18describesdeploymentandtheIISwebserversoftware.
Part4:Security:Inthispart,you'lllookatASP.
NET'srichcomplementofsecurityfeatures.
You'llstartwithahigh-leveloverviewofsecurityconceptsinChapter19andthenlearntheinsandoutsofformsauthentication(Chapter20)andthemembershipfeaturethatworkswithit(Chapter21).
InChapter22you'lltackleWindowsauthentication,andinChapter23you'lllearnhowtorestrictauthenticateduserswithsophisticatedauthorizationrulesanduserole-basedsecurity.
InChapter24you'llexploretheprofilesfeature—aprebuiltsolutionforstoringuser-specificinformation;inChapter25you'llgoonestepfurtherandlearnhowtoprotectthedatayoustoreinadatabaseaswellastheinformationyousendinaURLwithencryption.
Finally,Chapter26showshowyoucanplugintotheASP.
NETsecuritymodelbydesigningacustommembershipprovider.
Part5:AdvancedUserInterface:Thispartshowshowyoucanextendwebpageswithadvancedtechniques.
InChapters27you'llgetanintroductiontocustomcontrols.
InChapter28you'llbranchouttouseGDI+forhandcraftedgraphics.
InChapters29and30,you'llconsiderhowtouseJavaScriptandAjaxtechniquestomakewebpagesmoredynamic(byincorporatingeffectssuchastextautocompletionanddrag-and-drop)andmoreresponsive(byreactingtoclient-sideeventsandseamlesslyrefreshingthewebpage).
Finally,Chapter31exploresASP.
NET'sWebPartsfeature,whichallowsyoutoeasilycreatewebportals.
Part6:NewDirections:Inthispart,you'llconsidersomeofthemostexcitinginnovationsinmodernwebdevelopment.
InChapter32you'llexploreASP.
NETMVC,anewalternativetotheclassicwebformsmodelthatgivesdeveloperscompletecontroloverHTMLrenderingandURLstructure.
InChapter33you'llconsiderASP.
NETDynamicData,whichistheperfectsolutionforquicklybuildingapplicationsthatrevolvearoundviewingandeditingtheinformationinadatabase.
Finally,inChapter34you'lldiveintotheworldofSilverlight,aMicrosoft-builtbrowserplug-inthatgivesyoutheabilitytobringrichgraphics,animation,sound,andvideotoordinarywebpagesonavarietyofbrowsersandoperatingsystems.
WhoIsThisBookForThisbookisintendedasaprimerforprofessionaldeveloperswhohaveareasonableknowledgeofserver-sidewebdevelopment.
Thisbookdoesn'tprovideanexhaustivelookateveryingredientinthe.
NETFramework—infact,suchabookwouldrequiretwiceasmanypages.
Instead,thisbookaimstoprovideanintelligentintroductiontoASP.
NETforprofessionalprogrammerswhodon'twanttorehashthebasics.
Alongtheway,you'llfocusonothercornersofthe.
NETFrameworkthatyou'llneedinordertobuildprofessionalwebapplications,includingdataaccessandXML.
Usingthesefeatures,you'llbeabletocreatenext-generationwebsiteswiththebesttoolsonhandtoday.
Thisbookisalsorelentlesslypractical.
Youwon'tlearnjustaboutfeatures;you'llalsolearnaboutthereal-worldtechniquesthatcantakeyourwebsitetothenextlevel.
Laterchaptersarededicatedtocutting-edgetopicssuchascustomcontrols,dynamicgraphics,advancedsecurity,andhigh-performancedataaccess,allwiththegoalofgivingyoueverythingyouneedtobuildprofessionalwebapplications.
Togetthemostfromthisbook,youshouldbefamiliarwiththesyntaxoftheC#languageandwithobject-orientedconcepts.
Youdon'tneedtohaveexperiencewithapreviousversionofASP.
NET,INTRODUCTIONxxxvibecauseallthefundamentalsarecoveredinthisbook.
Ifyou'reanexperiencedJavaorC++developerwithno.
NETexperience,youshouldconsidersupplementingthisbookwithanintroductionto.
NET,suchasProC#2010andthe.
NET4PlatformbyAndrewTroelsen(Apress,2010).
WhatDoYouNeedtoUseThisBookTodevelopandtestASP.
NETwebapplications,youneedVisualStudio2010.
Althoughyoucouldtheoreticallywritecodebyhand,thesheertediumandthelikelihoodoferrormeanthisapproachisneverusedinaprofessionalenvironment.
Additionally,ifyouplantohostASP.
NETwebsites,you'llneedtouseaserver-basedversionofWindows,suchasWindowsServer2003orWindowsServer2008.
You'llalsoneedtoinstallIIS(InternetInformationServices),thewebhostingsoftwarethat'spartoftheWindowsoperatingsystem.
IISisdescribedinChapter18.
ThisbookincludesseveralexamplesthatusesampledatabasesthatareincludedwithSQLServertodemonstratedataaccesscode,securitytechniques,andotherfeatures.
YoucanuseanyversionofSQLServertotrytheseexamples,includingSQLServerExpress,whichisincludedwithsomeversionsofVisualStudio(andfreelydownloadableathttp://www.
microsoft.
com/express/database).
Ifyouuseotherrelationaldatabaseengines,thesameconceptswillapply,butyouwillneedtomodifytheexamplecode.
CustomerSupportWealwaysvaluehearingfromourreaders,andwewanttoknowwhatyouthinkaboutthisbook—whatyouliked,whatyoudidn'tlike,andwhatyouthinkwecandobetternexttime.
Youcansendyourcommentsbye-mailtofeedback@apress.
com.
Pleasebesuretomentionthebooktitleinyourmessage.
SampleCodeTodownloadthesamplecode,visittheApresswebsiteathttp://www.
apress.
com,andsearchforthisbook.
Youcanthendownloadthesamplecode,whichiscompressedintoasingleZIPfile.
Beforeyouusethecode,you'llneedtouncompressitusingautilitysuchasWinZip.
Codeisarrangedintoseparatedirectoriesbychapter.
Beforeusingthecode,refertotheaccompanyingreadme.
txtfileforinformationaboutotherprerequisitesandconsiderations.
BonusChaptersTheApresswebsitealsoincludesseveraladditionalchaptersthatyoucandownloadasPDFs.
Thesechaptersincludecontentthatcouldn'tbeincludedinthisbookbecauseofspacelimitationsandisn'tconsideredasimportanttoASP.
NETwebdevelopment.
Here'swhatyou'llfind:BonusChapter1,"ResourcesandLocalization":ThischapterdescribeshowtouseresourcesandlocalizationinASP.
NETwebsites.
It'sanessentialchapterfordeveloperswhoneedtocreatewebsitesthatcanbeviewedinmultiplelanguages.
BonusChapter2,"Design-TimeSupport":Thischapterdescribeshowtoadddesign-timesupporttoyourowncustomcontrolssothattheybehavenicelyintheVisualStudioenvironment,takechargeoftheirownpropertyserialization,andsupportadvanceddesignerfeaturessuchassmarttags.
INTRODUCTIONxxxviiNoteThebonuschaptersarereprintedfromthepreviouseditionofthisbook.
TheinformationinthesechaptersstillappliestoASP.
NET4,becausethesefeatureshaven'tchanged.
ErrataWe'vemadeeveryefforttomakesurethetextandthecodecontainnoerrors.
However,nooneisperfect,andthereforemistakesdooccur.
Ifyoufindanerrorinthebook,suchasaspellingmistakeorafaultypieceofcode,wewouldbegratefultohearaboutit.
Bysendinginerrata,youmaysaveanotherreaderhoursoffrustration,andyou'llbehelpingusprovidehigher-qualityinformation.
Simplye-mailtheproblemtosupport@apress.
com,whereyourinformationwillbecheckedandpostedontheerratapageorusedinsubsequenteditionsofthebook.
Youcanviewerratafromthebook'sdetailpage.
美国高防服务器提速啦专业提供美国高防服务器,美国高防服务器租用,美国抗攻击服务器,高防御美国服务器租用等。我们的海外高防服务器带给您坚不可摧的DDoS防护,保障您的业务不受攻击影响。HostEase美国高防服务器位于加州和洛杉矶数据中心,均为国内访问速度最快最稳定的美国抗攻击机房,带给您快速的访问体验。我们的高防服务器配有最高层级的DDoS防护系统,每款抗攻击服务器均拥有免费DDoS防护额度,让您...
Hostodo 算是比较小众的海外主机商,这次九月份开学季有提供促销活动。不过如果我们有熟悉的朋友应该知道,这个服务商家也是比较时间久的,而且商家推进活动比较稳,每个月都有部分活动。目前有提供机房可选斯波坎、拉斯维加斯和迈阿密。从机房的地理位置和实际的速度,中文业务速度应该不是优化直连的,但是有需要海外业务的话一般有人选择。以前一直也持有他们家的年付12美元的机器,后来用不到就取消未续约。第一、开...
BuyVM 商家算是有一些年头,从早年提供低价便宜VPS主机深受广大网友抢购且也遭到吐槽的是因为审核账户太过于严格。毕竟我们国内的个人注册账户喜欢账户资料乱写,毕竟我们看英文信息有些还是比较难以识别的,于是就注册信息的时候随便打一些字符,这些是不能通过的。前几天,我们可以看到BUYVM商家有新增加迈阿密机房,而且商家有提供大硬盘且不限制流量的VPS主机,深受有一些网友的喜欢。目前,BUYVM商家有...
selectedindexchanged为你推荐
主页改不了浏览器主页改不了深圳公交车路线深圳公交线路渗透测试软件测试与渗透测试那个工作有前途公章制作如何制作公章微信如何建群微信如何建群照片转手绘有没有一种软件是可以把一张照片变成手绘的图片,给推荐下网站联盟怎样进入网站联盟网站联盟百度网盟是什么,怎么加入网页打开很慢为什么我打开浏览器的时候,网页打开的很慢?宽带接入服务器什么是宽带接入系统?怎样绕过宽带接入系统上网
网站空间申请 成都虚拟主机 西部数码vps 已经备案域名 中国万网域名 域名抢注工具 ftp空间 国内免备案主机 rak机房 好看的桌面背景图片 镇江联通宽带 免费ftp站点 河南服务器 卡巴斯基永久免费版 蜗牛魔方 数字域名 七夕快乐英文 免费个人空间 河南移动网 免费高速空间 更多