ProASP.
NET3.
5inC#2008SecondEditionMatthewMacDonaldandMarioSzpusztaProASP.
NET3.
5inC#2008,SecondEditionCopyright2007byMatthewMacDonaldandMarioSzpusztaAllrightsreserved.
Nopartofthisworkmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical,includingphotocopying,recording,orbyanyinformationstorageorretrievalsystem,withoutthepriorwrittenpermissionofthecopyrightownerandthepublisher.
ISBN-13(pbk):978-1-59059-893-1ISBN-10(pbk):1-59059-893-8PrintedandboundintheUnitedStatesofAmerica987654321Trademarkednamesmayappearinthisbook.
Ratherthanuseatrademarksymbolwitheveryoccurrenceofatrademarkedname,weusethenamesonlyinaneditorialfashionandtothebenefitofthetrademarkowner,withnointentionofinfringementofthetrademark.
LeadEditor:JonathanHassellTechnicalReviewer:AndyOlsenEditorialBoard:SteveAnglin,EwanBuckingham,TonyCampbell,GaryCornell,JonathanGennick,JasonGilmore,KevinGoff,JonathanHassell,MatthewMoodie,JosephOttinger,JeffreyPepper,BenRenow-Clarke,DominicShakeshaft,MattWade,TomWelshProjectManager:DeniseS.
LincolnCopyEditors:AmiKnox,DamonLarson,SusannahPfalzerAssociateProductionDirector:KariBrooks-CoponyProductionEditor:KatieStenceCompositor:PatChristensonProofreaders:LisaHamiltonandLindaSeifertIndexer:BroccoliInformationManagementArtist:AprilMilneCoverDesigner:KurtKramesManufacturingDirector:TomDebolskiDistributedtothebooktradeworldwidebySpringer-VerlagNewYork,Inc.
,233SpringStreet,6thFloor,NewYork,NY10013.
Phone1-800-SPRINGER,fax201-348-4505,e-mailorders-ny@springer-sbm.
com,orvisithttp://www.
springeronline.
com.
Forinformationontranslations,pleasecontactApressdirectlyat2855TelegraphAvenue,Suite600,Berkeley,CA94705.
Phone510-549-5930,fax510-549-5939,e-mailinfo@apress.
com,orvisithttp://www.
apress.
com.
Theinformationinthisbookisdistributedonan"asis"basis,withoutwarranty.
Althougheveryprecautionhasbeentakeninthepreparationofthiswork,neithertheauthor(s)norApressshallhaveanyliabilitytoanypersonorentitywithrespecttoanylossordamagecausedorallegedtobecauseddirectlyorindirectlybytheinformationcontainedinthiswork.
Thesourcecodeforthisbookisavailabletoreadersathttp://www.
apress.
com.
ivContentsataGlanceAbouttheAuthorsxxixAbouttheTechnicalReviewerxxxiIntroductionxxxiiiPART1CoreConceptsCHAPTER1IntroducingASP.
NET3CHAPTER2VisualStudio23CHAPTER3WebForms.
71CHAPTER4ServerControls115CHAPTER5ASP.
NETApplications167CHAPTER6StateManagement.
219PART2DataAccessCHAPTER7ADO.
NETFundamentals259CHAPTER8DataComponentsandtheDataSet299CHAPTER9DataBinding341CHAPTER10RichDataControls385CHAPTER11CachingandAsynchronousPages451CHAPTER12FilesandStreams497CHAPTER13LINQ.
531CHAPTER14XML587PART3BuildingASP.
NETWebsitesCHAPTER15UserControls.
645CHAPTER16ThemesandMasterPages.
665CHAPTER17WebsiteNavigation695CHAPTER18WebsiteDeployment745vPART4SecurityCHAPTER19TheASP.
NETSecurityModel827CHAPTER20FormsAuthentication859CHAPTER21Membership.
885CHAPTER22WindowsAuthentication.
939CHAPTER23AuthorizationandRoles975CHAPTER24Profiles1009CHAPTER25Cryptography.
1041CHAPTER26CustomMembershipProviders1071PART5AdvancedUserInterfaceCHAPTER27CustomServerControls1109CHAPTER28Design-TimeSupport.
1151CHAPTER29DynamicGraphicsandGDI+1183CHAPTER30PortalswithWebPartPages1215PART6Client-SideProgrammingCHAPTER31JavaScriptandAjaxTechniques.
1273CHAPTER32ASP.
NETAJAX1323CHAPTER33Silverlight1379INDEX.
1441viiContentsAbouttheAuthorsxxixAbouttheTechnicalReviewerxxxiIntroductionxxxiiiPART1CoreConceptsCHAPTER1IntroducingASP.
NET3TheEvolutionofWebDevelopment3TheEarlyWebDevelopmentWorld4What'sWrongwithClassicASP4ASP.
NET.
6SevenImportantFactsAboutASP.
NET6Fact1:ASP.
NETIsIntegratedwiththe.
NETFramework.
7Fact2:ASP.
NETIsCompiled,NotInterpreted.
7Fact3:ASP.
NETIsMultilanguage9Fact4:ASP.
NETIsHostedbytheCommonLanguageRuntime11Fact5:ASP.
NETIsObject-Oriented13Fact6:ASP.
NETIsMultideviceandMultibrowser14Fact7:ASP.
NETIsEasytoDeployandConfigure15ASP.
NET3.
5:TheStoryContinues15ASP.
NET2.
016ASP.
NET3.
517Silverlight20Summary.
21CHAPTER2VisualStudio23The.
NETDevelopmentModel.
24TheCompiler.
24TheVisualStudioIDE.
25WebsitesandWebProjects.
26CreatingaProjectlessWebsite26Multitargeting29DesigningaWebPage.
30viiiCONTENTSTheVisualStudioIDE.
36SolutionExplorer38DocumentWindow.
39Toolbox39ErrorListandTaskList40ServerExplorer42TheCodeEditor42AddingAssemblyReferences43IntelliSenseandOutlining46TheCodeModel48HowCode-BehindFilesAreConnectedtoPages51HowControlTagsAreConnectedtoPageVariables52HowEventsAreConnectedtoEventHandlers53WebProjects.
55CreatingaWebProject56MigratingaWebsitefromaPreviousVersionofVisualStudio58VisualStudioDebugging59Single-StepDebugging60VariableWatches63AdvancedBreakpoints64VisualStudioMacros65TheWebDevelopmentHelper.
67Summary.
69CHAPTER3WebForms71PageProcessing.
71HTMLForms72DynamicUserInterface73TheASP.
NETEventModel.
74AutomaticPostbacks75ViewState77XHTMLCompliance82WebFormsProcessingStages86PageFrameworkInitialization.
87UserCodeInitialization88Validation.
88EventHandling89AutomaticDataBinding.
89Cleanup90APageFlowExample.
90ThePageAsaControlContainer92ShowingtheControlTree93ThePageHeader97DynamicControlCreation98CONTENTSixThePageClass.
99Session,Application,andCache.
100Request100Response.
102Server104User107Trace107AccessingtheHTTPContextinAnotherClass113Summary.
114CHAPTER4ServerControls.
115TypesofServerControls115TheServerControlHierarchy116HTMLServerControls118TheHtmlControlClass119TheHtmlContainerControlClass.
119TheHtmlInputControlClass.
119TheHTMLServerControlClasses120SettingStyleAttributesandOtherProperties122ProgrammaticallyCreatingServerControls.
123HandlingServer-SideEvents.
125WebControls.
127TheWebControlBaseClass129BasicWebControlClasses130Units.
132Enumerations132Colors.
133Fonts133Focus135TheDefaultButton136ScrollablePanels137HandlingWebControlEvents137TheListControls.
140TheSelectableListControls142TheBulletedListControl.
144InputValidationControls146TheValidationControls146TheValidationProcess.
147TheBaseValidatorClass148TheRequiredFieldValidatorControl150TheRangeValidatorControl.
150TheCompareValidatorControl151TheRegularExpressionValidatorControl151xCONTENTSTheCustomValidatorControl.
154TheValidationSummaryControl156UsingtheValidatorsProgrammatically157ValidationGroups158RichControls.
160TheAdRotatorControl161TheCalendarControl163Summary.
165CHAPTER5ASP.
NETApplications.
167AnatomyofanASP.
NETApplication.
167TheApplicationDomain.
168ApplicationLifetime169ApplicationUpdates169ApplicationDirectoryStructure.
170Theglobal.
asaxApplicationFile171ApplicationEvents173DemonstratingApplicationEvents175ASP.
NETConfiguration.
176Themachine.
configFile.
176Theweb.
configFile179Settings183ReadingandWritingConfigurationSectionsProgrammatically187TheWebsiteAdministrationTool(WAT)190ExtendingtheConfigurationFileStructure192EncryptingConfigurationSections196.
NETComponents.
198CreatingaComponent199UsingaComponentThroughtheApp_CodeDirectory.
200UsingaComponentThroughtheBinDirectory.
201ExtendingtheHTTPPipeline203HTTPHandlersandHTTPModules.
204CreatingaCustomHTTPHandler206ConfiguringaCustomHTTPHandler207RegisteringHTTPHandlersWithoutConfiguringIIS208CreatinganAdvancedHTTPHandler210CreatinganHTTPHandlerforNon-HTMLContent212CreatingaCustomHTTPModule215Summary.
218CONTENTSxiCHAPTER6StateManagement.
219ASP.
NETStateManagement.
219ViewState222AViewStateExample223StoringObjectsinViewState224RetainingMemberVariables227AssessingViewState.
228ViewStateSecurity230TransferringInformationBetweenPages231TheQueryString.
231Cross-PagePosting233Cookies240SessionState241SessionArchitecture241UsingSessionState243ConfiguringSessionState244SecuringSessionState250ApplicationState.
251StaticApplicationVariables.
253Summary.
255PART2DataAccessCHAPTER7ADO.
NETFundamentals.
259TheADO.
NETArchitecture.
260ADO.
NETDataProviders260StandardizationinADO.
NET262SQLServer2005263FundamentalADO.
NETClasses263TheConnectionClass.
265ConnectionStrings.
265TestingaConnection266ConnectionPooling.
268ConnectionStatistics270TheCommandandDataReaderClasses270CommandBasics271TheDataReaderClass272TheExecuteReader()MethodandtheDataReader.
273TheExecuteScalar()Method278xiiCONTENTSTheExecuteNonQuery()Method279SQLInjectionAttacks.
279UsingParameterizedCommands282CallingStoredProcedures.
284Transactions286TransactionsandASP.
NETApplications287IsolationLevels.
291Savepoints.
293Provider-AgnosticCode294CreatingtheFactory.
294CreateObjectswithFactory295AQuerywithProvider-AgnosticCode296Summary.
297CHAPTER8DataComponentsandtheDataSet299BuildingaDataAccessComponent299TheDataPackage300TheStoredProcedures302TheDataUtilityClass.
303TestingtheDatabaseComponent.
309DisconnectedData311WebApplicationsandtheDataSet312XMLIntegration313TheDataSet313TheDataAdapterClass315FillingaDataSet316WorkingwithMultipleTablesandRelationships317SearchingforSpecificRows321UsingtheDataSetinaDataAccessClass.
322DataBinding323TheDataViewClass323SortingwithaDataView324FilteringwithaDataView.
325AdvancedFilteringwithRelationships327CalculatedColumns328TypedDataSets.
330CustomTableAdapters.
331CreatingaTypedDataSet332DissectingtheTypedDataSet.
334UsingtheTypedDataSet337Summary.
339CONTENTSxiiiCHAPTER9DataBinding341BasicDataBinding.
341Single-ValueBinding342OtherTypesofExpressions.
344Repeated-ValueBinding348DataSourceControls355ThePageLifeCyclewithDataBinding356TheSqlDataSource.
357SelectingRecords.
357ParameterizedCommands360HandlingErrors.
364UpdatingRecords365DeletingRecords369InsertingRecords370DisadvantagesoftheSqlDataSource.
370TheObjectDataSource371SelectingRecords.
372UpdatingRecords377UpdatingwithaDataObject377TheLimitsoftheDataSourceControls381TheProblem381AddingtheExtraItems.
382HandlingtheExtraOptionswiththeSqlDataSource.
383HandlingtheExtraOptionswiththeObjectDataSource384Summary.
384CHAPTER10RichDataControls385TheGridView.
386DefiningColumns386FormattingtheGridView390FormattingFields390Styles.
392Formatting-SpecificValues395GridViewRowSelection.
397UsingSelectiontoCreateaMaster-DetailsForm.
398TheSelectedIndexChangedEvent400UsingaDataFieldAsaSelectButton401SortingtheGridView.
401SortingwiththeSqlDataSource402SortingwiththeObjectDataSource402SortingandSelection.
404AdvancedSorting405xivCONTENTSPagingtheGridView.
406AutomaticPaging407CustomPaginationwiththeObjectDataSource.
408CustomizingthePagerBar411GridViewTemplates412UsingMultipleTemplates414EditingTemplatesinVisualStudio415BindingtoaMethod.
416HandlingEventsinaTemplate417EditingwithaTemplate.
418TheListView423Grouping426Paging428TheDetailsViewandFormView.
429TheDetailsView429TheFormView.
432AdvancedGrids.
433SummariesintheGridView.
434AParent/ChildViewinaSingleTable435EditingaFieldUsingaLookupTable438ServingImagesfromaDatabase440DetectingConcurrencyConflicts.
445Summary.
450CHAPTER11CachingandAsynchronousPages.
451UnderstandingASP.
NETCaching451OutputCaching.
452DeclarativeOutputCaching.
452CachingandtheQueryString453CachingwithSpecificQueryStringParameters454CustomCachingControl455CachingwiththeHttpCachePolicyClass456Post-CacheSubstitutionandFragmentCaching457CacheProfiles.
459CacheConfiguration.
460DataCaching.
461AddingItemstotheCache462ASimpleCacheTest464CachePriorities.
465CachingwiththeDataSourceControls466CacheDependencies469FileandCacheItemDependencies469AggregateDependencies.
470CONTENTSxvTheItemRemovedCallback471UnderstandingSQLCacheNotifications473CacheNotificationsinSQLServer2000andSQLServer7.
474CacheNotificationsinSQLServer2005andSQLServer2008479CustomCacheDependencies481ABasicCustomCacheDependency.
482ACustomCacheDependencyUsingMessageQueues483AsynchronousPages485CreatinganAsynchronousPage.
486QueryingDatainanAsynchronousPage.
488HandlingErrors.
490UsingCachingwithAsynchronousTasks492MultipleAsynchronousTasksandTimeouts.
495Summary.
496CHAPTER12FilesandStreams.
497WorkingwiththeFileSystem497TheDirectoryandFileClasses498TheDirectoryInfoandFileInfoClasses.
500TheDriveInfoClass503WorkingwithAttributes504FilterFileswithWildcards506RetrievingFileVersionInformation.
506ThePathClass507AFileBrowser.
510ReadingandWritingFileswithStreams514TextFiles.
516BinaryFiles517UploadingFiles518MakingFilesSafeforMultipleUsers520Compression.
525Serialization.
526Summary.
529CHAPTER13LINQ.
531LINQBasics.
531DeferredExecution.
533HowLINQWorks.
534LINQExpressions534LINQExpressions"UndertheHood"541LINQtoDataSet544TypedDataSets.
546NullValues547xviCONTENTSLINQtoSQL.
547DataEntityClasses.
548TheDataContext.
550LINQtoSQLQueries"UndertheHood"551LINQtoSQLandDatabaseComponents554SelectingaSingleRecordorValue.
556GeneratingDataClassesAutomatically557Relationships.
563GeneratingMethodsforStoredProcedures.
571CommittingChanges573TheLinqDataSource.
578DisplayingData.
579GettingRelatedData582EditingData.
583Validation.
583Summary.
586CHAPTER14XML587WhenDoesUsingXMLMakeSense587AnIntroductiontoXML588TheAdvantagesofXML.
589Well-FormedXML.
590XMLNamespaces.
590XMLSchemas.
592Stream-BasedXMLProcessing594WritingXMLFiles594ReadingXMLFiles597In-MemoryXMLProcessing600TheXmlDocument601TheXPathNavigator605TheXDocument607SearchingXMLContent612SearchingwithXmlDocument.
612SearchingXmlDocumentwithXPath615SearchingXDocumentwithLINQ617ValidatingXMLContent619ABasicSchema619ValidatingwithXmlDocument.
619ValidatingwithXDocument621TransformingXMLContent622ABasicStylesheet622UsingXslCompiledTransform623CONTENTSxviiUsingtheXmlControl625TransformingXMLwithLINQtoXML625XMLDataBinding.
627NonhierarchicalBinding.
627UsingXPath.
629NestedGrids632HierarchicalBindingwiththeTreeView633UsingXSLT635BindingtoXMLContentfromOtherSources.
637UpdatingXMLThroughtheXmlDataSource637XMLandtheADO.
NETDataSet.
638ConvertingtheDataSettoXML.
639AccessingaDataSetAsXML640Summary.
642PART3BuildingASP.
NETWebsitesCHAPTER15UserControls.
645UserControlBasics645CreatingaSimpleUserControl.
646ConvertingaPagetoaUserControl.
647AddingCodetoaUserControl648HandlingEvents648AddingProperties.
649UsingCustomObjects651AddingEvents.
654ExposingtheInnerWebControl657DynamicallyLoadingUserControls657PortalFrameworks.
658PartialPageCaching661VaryByControl662SharingCachedControls663Summary.
663CHAPTER16ThemesandMasterPages665CascadingStyleSheets665CreatingaStylesheet.
665ApplyingStylesheetRules668xviiiCONTENTSThemes670ThemeFoldersandSkins671ApplyingaSimpleTheme672HandlingThemeConflicts673CreatingMultipleSkinsfortheSameControl674SkinswithTemplatesandImages675UsingCSSinaTheme677ApplyingThemesThroughaConfigurationFile677ApplyingThemesDynamically678StandardizingWebsiteLayout.
680MasterPageBasics680ASimpleMasterPage681ASimpleContentPage683DefaultContent.
684MasterPageswithTablesandCSSLayout.
685MasterPagesandRelativePaths687ApplyingMasterPagesThroughaConfigurationFile.
688AdvancedMasterPages689InteractingwiththeMasterPageClass689DynamicallySettingaMasterPage690NestingMasterPages691Summary.
693CHAPTER17WebsiteNavigation695PageswithMultipleViews.
695TheMultiViewControl696TheWizardControl.
700SiteMaps707DefiningaSiteMap708BindingtoaSiteMap.
710Breadcrumbs711ShowingaPortionoftheSiteMap713TheSiteMapObjects.
716AddingCustomSiteMapInformation.
718CreatingaCustomSiteMapProvider.
718URLMapping.
725SecurityTrimming726TheTreeViewControl.
728TheTreeNode729PopulatingNodesonDemand.
731TreeViewStyles733CONTENTSxixTheMenuControl.
737MenuStyles740MenuTemplates.
741Summary.
743CHAPTER18WebsiteDeployment745InternetInformationServices(IIS)745IISWebsitesandVirtualDirectories746IISManagementConsoleandIISConfiguration747MappingWebsites,VirtualDirectories,andFilestoURLs748DivingintotheArchitectureofIIS750InstallingIIS.
765ManagingWebsites771ManagingVirtualDirectoriesandWebsiteswithIIS5.
xandIIS6.
0.
772ManagingApplicationPoolsinIIS6.
0778ManagingVirtualDirectoriesandWebsiteswithIIS7.
0.
784ManagingApplicationPoolsinIIS7.
0796DeployingYourASP.
NETApplications798VerifyingtheASP.
NETInstallationonIIS5.
xandIIS6.
0800ASP.
NETSide-By-SideExecutiononIIS5.
xandIIS6.
0.
801ASP.
NETSide-By-SideExecutiononIIS7.
0803ConfiguringHTTPRuntimeSettingswhenDeployingonIIS5.
x803CompilationModelsinASP.
NET804DeployingwithVisualStudio.
808VisualStudio2005WebDeploymentProjects809TheVirtualPathProviderinASP.
NET815HealthMonitoringinASP.
NET.
819UnderstandingtheBasicStructure.
820EventsandProviders820Summary.
823PART4SecurityCHAPTER19TheASP.
NETSecurityModel827WhatItMeanstoCreateSecureSoftware.
827UnderstandingPotentialThreats.
828SecureCodingGuidelines828UnderstandingGatekeepers829UnderstandingtheLevelsofSecurity.
830Authentication.
831Authorization.
832xxCONTENTSConfidentialityandIntegrity.
833PullingItAllTogether.
833InternetInformationServicesSecurity.
835AuthenticationandAuthorizationonIIS5.
xandIIS6.
0835SecurityConfigurationonIIS7.
0838UnderstandingSecureSocketsLayer843ASP.
NETSecurityArchitecture852Authentication.
853Authorization.
855TheSecurityContext855MembershipandRolesAPIs857Summary.
858CHAPTER20FormsAuthentication.
859IntroducingFormsAuthentication.
859WhyUseFormsAuthentication860WhyWouldYouNotUseFormsAuthentication862WhyNotImplementCookieAuthenticationYourself863TheFormsAuthenticationClasses864ImplementingFormsAuthentication.
865ConfiguringFormsAuthentication865DenyingAccesstoAnonymousUsers869CreatingaCustomLoginPage869CustomCredentialsStore876PersistentCookiesinFormsAuthentication877IIS7.
0andFormsAuthentication878Summary.
884CHAPTER21Membership885IntroducingtheASP.
NETMembershipAPI.
885UsingtheMembershipAPI888ConfiguringFormsAuthentication889CreatingtheDataStore890ConfiguringConnectionStringandMembershipProvider.
896CreatingandAuthenticatingUsers.
900UsingtheSecurityControls.
902TheLoginControl904TheLoginStatusControl914TheLoginViewControl.
915ThePasswordRecoveryControl916TheChangePasswordControl.
921TheCreateUserWizardControl922CONTENTSxxiConfiguringMembershipinIIS7.
0.
926ConfiguringProvidersandUsers.
926UsingtheMembershipAPIwithOtherApplications928UsingtheMembershipClass.
930RetrievingUsersfromtheStore930UpdatingUsersintheStore.
933CreatingandDeletingUsers933ValidatingUsers934UsingMembershipinWindowsForms.
935Summary.
937CHAPTER22WindowsAuthentication.
939IntroducingWindowsAuthentication939WhyUseWindowsAuthentication940WhyWouldYouNotUseWindowsAuthentication941MechanismsforWindowsAuthentication942ImplementingWindowsAuthentication948ConfiguringIIS5.
xorIIS6.
0948ConfiguringIIS7.
0950ConfiguringASP.
NET952DenyingAccesstoAnonymousUsers955AccessingWindowsUserInformation957Impersonation.
962ImpersonationinWindows2000963ImpersonationonWindowsXP964ImpersonationandDelegationonWindowsServer2003964ImpersonationonWindowsVista967ImpersonationandDelegationonWindowsServer2008968ConfiguredImpersonation968ProgrammaticImpersonation970Summary.
973CHAPTER23AuthorizationandRoles975URLAuthorization.
975AuthorizationRules976FileAuthorization981AuthorizationChecksinCode982UsingtheIsInRole()Method.
982UsingthePrincipalPermissionClass983UsingtheRolesAPIforRole-BasedAuthorization985UsingtheLoginViewControlwithRoles.
991AccessingRolesProgrammatically.
992UsingtheRolesAPIwithWindowsAuthentication994xxiiCONTENTSProtectingNon-ASP.
NETResourcesinIIS5and6.
997AddingaFileTypeMapping997WritingaCustomHTTPHandler998AuthorizationandRolesinIIS7.
0.
1000AuthorizationwithASP.
NETRolesinIIS7.
01002ManagingASP.
NETRoleswithIIS7.
01005Summary.
1006CHAPTER24Profiles1009UnderstandingProfiles.
1009ProfilePerformance1009HowProfilesStoreData.
1010ProfilesandAuthentication1011Profilesvs.
CustomDataComponents.
1011UsingtheSqlProfileProvider1012CreatingtheProfileTables1012ConfiguringtheProvider1015DefiningProfileProperties.
1016UsingProfileProperties1017ProfileSerialization.
1018ProfileGroups1020ProfilesandCustomDataTypes.
1021TheProfilesAPI.
1024AnonymousProfiles1026CustomProfileProviders1029TheCustomProfileProviderClasses1029DesigningtheFactoredProfileProvider.
1031CodingtheFactoredProfileProvider1033TestingtheFactoredProfileProvider1037Summary.
1040CHAPTER25Cryptography.
1041EncryptingData:ConfidentialityMatters1041The.
NETCryptographyNamespace.
1042Understandingthe.
NETCryptographyClasses.
1046SymmetricEncryptionAlgorithms1047AsymmetricEncryption1048TheAbstractEncryptionClasses1049TheICryptoTransformInterface1050TheCryptoStreamClass1050CONTENTSxxiiiEncryptingSensitiveData1051ManagingSecrets.
1052UsingSymmetricAlgorithms.
1053UsingAsymmetricAlgorithms.
1058EncryptingSensitiveDatainaDatabase1061EncryptingtheQueryString1065WrappingtheQueryString1066CreatingaTestPage1069Summary.
1070CHAPTER26CustomMembershipProviders1071ArchitectureofCustomProviders.
1071BasicStepsforCreatingCustomProviders.
1073OverallDesignoftheCustomProvider1073DesigningandImplementingtheCustomStore1074ImplementingtheProviderClasses1082UsingtheCustomProviderClasses1102Summary.
1106PART5AdvancedUserInterfaceCHAPTER27CustomServerControls1109CustomServerControlBasics.
1109CreatingaBare-BonesCustomControl1110UsingaCustomControl1112CustomControlsintheToolbox1113CreatingaWebControlThatSupportsStyleProperties.
1114TheRenderingProcess1118DealingwithDifferentBrowsers.
1119TheHtmlTextWriter1119BrowserDetection1120BrowserProperties.
1122OverridingBrowserTypeDetection1124AdaptiveRendering1125ControlStateandEvents1127ViewState1127ControlState1129PostbackDataandChangeEvents.
1131TriggeringaPostback1133ExtendingExistingWebControls1135CompositeControls1135EndSidebarDerivedControls.
1138xxivCONTENTSTemplateControls1141CreatingaTemplateControl1141UsingCustomizedTemplates1143Styles.
1148Summary.
1150CHAPTER28Design-TimeSupport1151TheKeyPlayers1151Design-TimeAttributes1152ThePropertiesWindow1153AttributesandInheritance1157TheToolboxIcon1158WebResources.
1159CreatingaResource.
1159RetrievingaResource1160TextSubstitution.
1161CodeSerialization.
1162TypeConverters1162SerializationAttributes.
1170TypeEditors1172ControlDesigners.
1174Design-TimeHTML1175SmartTags1177Summary.
1182CHAPTER29DynamicGraphicsandGDI+1183TheImageMapControl.
1183CreatingHotspots.
1184HandlingHotspotClicks.
1185ACustomHotspot.
1186DrawingwithGDI+1188SimpleDrawing1189ImageFormatandQuality1191TheGraphicsClass.
1192UsingaGraphicsPath.
1194Pens.
1195Brushes1198EmbeddingDynamicGraphicsinaWebPage1199UsingthePNGFormat1200PassingInformationtoDynamicImages1201CustomControlsThatUseGDI+1204ChartingwithGDI+1208Summary.
1213CONTENTSxxvCHAPTER30PortalswithWebPartPages1215TypicalPortalPages.
1216BasicWebPartPages1217CreatingthePageDesign1218WebPartManagerandWebPartZoneControls1219AddingWebPartstothePage.
1221CustomizingthePage1224CreatingWebParts.
1226SimpleWebPartTasks1227DevelopingAdvancedWebParts1235WebPartEditors.
1244ConnectingWebParts1250CustomVerbsandWebParts1258UserControlsandAdvancedWebParts.
1259UploadingWebPartsDynamically1262AuthorizingWebParts1268FinalTasksforPersonalization1268Summary.
1269PART6Client-SideProgrammingCHAPTER31JavaScriptandAjaxTechniques1273JavaScriptEssentials1273TheHTMLDocumentObjectModel1274Client-SideEvents1275ScriptBlocks.
1277ManipulatingHTMLElements1279DebuggingJavaScript1280BasicJavaScriptExamples1282CreatingaJavaScriptPageProcessor1282UsingJavaScripttoDownloadImagesAsynchronously.
1285RenderingScriptBlocks1290ScriptInjectionAttacks1291RequestValidation1291DisablingRequestValidation.
1292CustomControlswithJavaScript1294Pop-UpWindows1294RolloverButtons1298Frames.
1301FrameNavigation1302InlineFrames1303xxviCONTENTSUnderstandingAjax1304TheXMLHttpRequestObject1305AnAjaxExample.
1307UsingAjaxwithClientCallbacks.
1311CreatingaClientCallback1311ClientCallbacks"UndertheHood"1317ClientCallbacksinCustomControls.
1318Summary.
1322CHAPTER32ASP.
NETAJAX.
1323IntroducingASP.
NETAJAX1323ASP.
NETAJAXontheClient:TheScriptLibraries1325ASP.
NETAJAXontheServer:TheScriptManager1325ServerCallbacks.
1326WebServicesinASP.
NETAJAX1327TheWebServiceProxy1334PlacingaWebMethodinaPage1336ASP.
NETAJAXApplicationServices.
1337ASP.
NETAJAXServerControls1344PartialRenderingwiththeUpdatePanel.
1344TimedRefresheswiththeTimer.
1351Time-ConsumingUpdateswithUpdateProgress.
1352DeeperintotheClientLibraries1355UnderstandingtheClientModel1356Object-OrientedProgramminginJavaScript.
1357TheWeb-PageFramework1364ControlExtenders1369InstallingtheASP.
NETAJAXControlToolkit1370TheAutoCompleteExtender.
1371TheASP.
NETAJAXControlToolkit1374Summary.
1378CHAPTER33Silverlight.
1379UnderstandingSilverlight.
1379Silverlightvs.
Flash1380SilverlightAdoption1382SilverlightandWPF1382InstallingSilverlightandtheVisualStudioExtensions1383CreatingaSilverlightProject.
1384TheHTMLEntryPage.
1385TheSilverlightInitializationScript.
1386TheXAMLPage1388TheXAMLCode-Behind.
1391CONTENTSxxviiPropertiesandEvents1392SilverlightCompilation.
1393SilverlightEssentials1394.
NETFrameworkClassesinSilverlight1395TheCanvas1396Text1401InteractingwithHTML1402IsolatedStorage1406SilverlightandASP.
NET.
1408ASP.
NETFutures.
1408CommunicatingBetweenSilverlightandASP.
NET.
1412Drawingin2D.
1412SimpleShapes1413PathsandGeometries1417Brushes1425Transparency1427Animation1429AnimationBasics1430DefininganAnimation1430AnInteractiveAnimationExample1434Transforms1437Summary.
1440INDEX1441xxixAbouttheAuthorsMATTHEWMACDONALDisanauthor,educator,andMicrosoftMVP.
He'saregularcontributortoprogrammingjournalsandtheauthorofmorethanadozenbooksabout.
NETprogramming,includingProWPF:WindowsPre-sentationFoundationin.
NET3.
0(Apress,2007),BeginningASP.
NET3.
5inC#2008(Apress,2007),andPro.
NET2.
0WindowsFormsandCustomCon-trolsinC#(Apress,2006).
HelivesinTorontowithhiswifeanddaughter.
MARIOSZPUSZTAworksasanarchitectintheDeveloperandPlatformGroupofMicrosoftAustria,andhelpssoftwarearchitectsoftopenterpriseandwebcustomerswithestablishingnewMicrosofttechnologies.
Forseveralyearshehasbeenfocusingonsecuresoftwaredevelopment,webservicesandinterop-erability,andintegrationofMicrosoftOfficeclientsandserversincustomapplications.
MariospeaksregularlyatlocalandinternationalconferencessuchasDevDaysandTechEdEuropeDevelopers,andhasbeenatechnicalcontentownerofTechEdEuropeDevelopersinthepasttwoyears,aswell.
xxxiAbouttheTechnicalReviewerANDYOLSENisafreelancedeveloperandconsultantbasedintheUnitedKingdom.
Andyhasbeenworkingwith.
NETsincethebeta1daysandhascoauthoredandreviewedseveralbooksforApress,coveringC#,VisualBasic,ASP.
NET,andothertopics.
Andyisakeenfootballandrugbyfanandenjoysrunningandskiing(badly).
AndylivesbytheseasideinSwanseawithhiswife,Jayne,andchildren,EmilyandThomas,whohavejustdiscoveredthethrillsofsurfingandlookmuchcoolerthanheeverwill!
xxxiiiIntroductionAsyounodoubtalreadyknow,ASP.
NETisMicrosoft'snext-generationtechnologyforcreatingserver-sidewebapplications.
It'sbuiltontheMicrosoft.
NETFramework,whichisaclusterofcloselyrelatednewtechnologiesthatrevolutionizeeverythingfromdatabaseaccesstodistributedapplica-tions.
ASP.
NETisoneofthemostimportantcomponentsofthe.
NETFramework—it'sthepartthatenablesyoutodevelophigh-performancewebapplications.
It'snothardtogetdevelopersinterestedinASP.
NET.
Withoutexaggeration,ASP.
NETisthemostcompleteplatformforwebdevelopmentthat'severbeenputtogether.
Itfaroutclassesitspre-decessor,ASP,whichwasdesignedasaquick-and-dirtysetoftoolsforinsertingdynamiccontentintoordinarywebpages.
Bycontrast,ASP.
NETisafull-blownplatformfordevelopingcomprehen-sive,blisteringlyfastwebapplications.
Inthisbook,you'lllearneverythingyouneedtomasterASP.
NET3.
5.
Ifyou'veprogrammedwithapreviousversionofASP.
NET,youcanfocusonnewfeaturessuchasLINQ(Chapter13),ASP.
NETAJAX(Chapter32),andSilverlight(Chapter33).
Ifyou'veneverprogrammedwithASP.
NET,you'llfindthatthisbookprovidesawell-pacedtourthatleadsyouthroughallthefundamentals,alongwithabackstagepassthatletsyouseehowtheASP.
NETinternalsreallywork.
TheonlyrequirementforthisbookisthatyouhaveasolidunderstandingoftheC#languageandthebasicsof.
NET.
Ifyou'reaseasonedJavaorC++developerbutyou'renewtoC#,youmayfinditeasiertostartwithabookabout.
NETfundamentals,suchasProC#2008andthe.
NET3.
5Platform,byAndrewTroelsen(Apress,2007).
WhatDoesThisBookCoverHereisaquickbreakdownofwhatyou'llfindinthisbook:Part1:CoreConcepts:You'llbegininChapter1withalookattheoverallASP.
NETplatform,the.
NETFramework,andanoverviewofthechangesthathavetakenplaceinASP.
NET3.
5.
InChapter2you'llbranchouttolearnthetoolsofthetrade—namely,VisualStudio2008.
InChapters3,4,5,and6you'lllearnthekeypartsoftheASP.
NETinfrastructure,suchastheweb-pagemodel,applicationconfiguration,andstatemanagement.
Asyoulearnthesecoreconcepts,you'llalsotakealow-levellookathowASP.
NETprocessesrequestsandmanagesthelifetimeofyourwebapplications.
You'llevenlearnhowtoextendtheASP.
NETarchitecture.
Part2:DataAccess:Thisparttacklesoneofthecoreproblemdomainsforallsoftwaredevelop-ment—accessingandmanipulatingdata.
InChapters7and8you'llconsiderthefundamentalsofADO.
NETastheyapplytowebapplicationsandlearnhowtodesigndataaccesscomponents.
InChapters9and10you'lllearnaboutASP.
NET'ssetofinnovativedataboundcontrolsthatletyouformatandpresentdatawithoutwritingpagesofcode.
Chapter11branchesoutintoadvancedcachingstrategiesthatensurefirst-classperformance.
Finally,Chapters12,13,and14movebeyondtheworldofADO.
NETtoshowyouhowtoworkwithfiles,LINQ,andXMLcontent.
xxxivINTRODUCTIONPart3:BuildingASP.
NETWebsites:Inthispartyou'lllearnaboutessentialtechniquesandfeaturesformanaginggroupsofwebpages.
You'llstartsimplywithusercontrolsinChapter15,whichallowyoutoreusesegmentsoftheuserinterface.
InChapter16you'llconsidertwonewASP.
NETinnovations—themes(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—anew,prebuiltsolutionforstoringuser-specificinformation;andinChapter25you'llgoonestepfurtherandlearnhowtoprotectthedatayoustoreinadatabaseaswellastheinformationyousendinaURLwithencryption.
Finally,Chapter26showshowyoucanplugintotheASP.
NETsecuritymodelbydesigningacustommembershipprovider.
Part5:AdvancedUserInterface:Thispartshowshowyoucanextendwebpageswithadvancedtechniques.
InChapters27and28you'lltacklecustomcontrols.
InChapter29you'llbranchouttouseGDI+forhandcraftedgraphics.
Finally,Chapter30exploresASP.
NET'sWebPartsfeature,whichallowsyoutoeasilycreatewebportals.
Part6:Client-SideProgramming:Inthispart,you'llconsidersomeofthemostexcitinginno-vationsinmodernwebdevelopment.
First,inChapters31and32,you'llconsiderhowtouseJavaScriptandAjaxtechniquesinyourASP.
NETwebpages.
You'lllearnhowtomakewebpagesmoredynamic(byincorporatingeffectsliketextautocompletionanddrag-and-drop)andmoreresponsive(byreactingtoclient-sideeventsandseamlesslyrefreshingthewebpage).
InChapter33,you'lldiveintotheworldofSilverlight,aMicrosoft-builtbrowserplug-inthatgivesyoutheabilitytobringrichgraphics,animation,sound,andvideotoordinarywebpagesonavarietyofbrowsers.
WhoIsThisBookForThisbookisintendedasaprimerforprofessionaldeveloperswhohaveareasonableknowledgeofserver-sidewebdevelopment.
Thisbookdoesn'tprovideanexhaustivelookateveryingredientinthe.
NETFramework—infact,suchabookwouldrequiretwiceasmanypages.
Instead,thisbookaimstoprovideanintelligentintroductiontoASP.
NETforprofessionalprogrammerswhodon'twanttorehashthebasics.
Alongtheway,you'llfocusonothercornersofthe.
NETFrameworkthatyou'llneedinordertobuildprofessionalwebapplications,includingdataaccessandXML.
Usingthesefeatures,you'llbeabletocreatenext-generationwebsiteswiththebesttoolsonhandtoday.
Thisbookisalsorelentlesslypractical.
Youwon'tjustlearnaboutfeatures—you'llalsolearnaboutthereal-worldtechniquesthatcantakeyourwebsitetothenextlevel.
Laterchaptersarededi-catedtocutting-edgetopicssuchascustomcontrols,dynamicgraphics,advancedsecurity,andhigh-performancedataaccess,allwiththegoalofgivingyoueverythingyouneedtobuildprofes-sionalwebapplications.
INTRODUCTIONxxxvTogetthemostfromthisbook,youshouldbefamiliarwiththesyntaxoftheC#languageandwithobject-orientedconcepts.
Youdon'tneedtohaveexperiencewithapreviousversionofASP.
NET,asallthefundamentalsarecoveredinthisbook.
Ifyou'reanexperiencedJavaorC++developerwithno.
NETexperience,youshouldconsidersupplementingthisbookwithanintroduc-tionto.
NET,suchasProC#2008andthe.
NET3.
5Platform,byAndrewTroelsen(Apress,2007).
WhatDoYouNeedtoUseThisBookTodevelopandtestASP.
NETwebapplications,youneedVisualStudio2008.
Althoughyoucouldtheoreticallywritecodebyhand,thesheertediumandthelikelihoodoferrormeanthisapproachisneverusedinaprofessionalenvironment.
NoteYoucanusethescaled-downVisualStudioWebDeveloper2008ExpressEdition,butyou'llrunintosignif-icantlimitationsonsomeoftheexamples.
Mostimportant,youcan'tuseVisualStudioWebDeveloper2008ExpressEditiontocreateclasslibraries,whichareanessentialpartofmoderncomponent-orienteddesign(althoughyoucanworkaroundthislimitationbyusingtwoexpresseditions—VisualStudioWebDeveloperExpressEditiontocreateyourwebsitesandVisualC#2008ExpressEditiontocreateyourcomponents).
Additionally,ifyouplantohostASP.
NETwebsites,you'llneedtouseWindowsXPProfessionalor(ideally)aserver-basedversionofWindows,suchasWindowsServer2003orWindowsServer2008.
You'llalsoneedtoinstallIIS(InternetInformationServices),thewebhostingsoftwarethat'spartoftheWindowsoperatingsystem.
IISisdescribedinChapter18.
Finally,thisbookincludesseveralexamplesthatusesampledatabasesthatareincludedwithSQLServertodemonstratedataaccesscode,securitytechniques,andotherfeatures.
Youcanuseanyver-sionofSQLServertotrytheseexamples,includingSQLServer2005ExpressEdition,whichisincludedwithsomeversionsofVisualStudio(andfreelydownloadableathttp://msdn.
microsoft.
com/sql/express).
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.
Codeisarrangedintosep-aratedirectoriesbychapter.
Beforeusingthecode,refertotheaccompanyingreadme.
txtfileforinformationaboutotherprerequisitesandconsiderations.
xxxviINTRODUCTIONBonusChaptersTheApresswebsitealsoincludesseveraladditionalchaptersthatyoucandownloadasPDFs.
Thesechaptersincludecontentthatcouldn'tbeincludedinthisbook(duetospacerequirements)andisn'tconsideredasimportanttoASP.
NETwebdevelopment.
Here'swhatyou'llfind:BonusChapter1:ThischapterdescribeshowtouseresourcesandlocalizationinASP.
NETwebsites.
It'sanessentialchapterfordeveloperswhoneedtocreatewebsitesthatcanbeviewedinmultiplelanguages.
BonusChapters2,3,and4:Thesechapterstacklewebservices,afeaturethatallowsyoutocreatecoderoutinesthatcanbecalledbyotherapplicationsovertheInternet.
Webservicesaremoreinterestingwhenconsideringrichclientdevelopment(becausetheyallowyoutogivewebfeaturestoordinarydesktopapplications),andthey'reintheprocessofbeingreplacedbyanewtechnologyknownasWCF(WindowsCommunicationFoundation).
Forthosereasons,webservicesaren'tcoveredinthisbook.
NoteThewebservicechaptersarereprintedfromthepreviouseditionofthisbook.
TheinformationinthesechaptersstillappliestoASP.
NET3.
5,becausethewebservicefeaturehasn'tchanged.
ErrataWe'vemadeeveryefforttomakesurethetextandthecodecontainnoerrors.
However,nooneisper-fect,andmistakesdooccur.
Ifyoufindanerrorinthebook,suchasaspellingmistakeorafaultypieceofcode,wewouldbegratefultohearaboutit.
Bysendinginerrata,youmaysaveanotherreaderhoursoffrustration,andyou'llbehelpingustoprovidehigher-qualityinformation.
Simplye-mailtheprob-lemtosupport@apress.
com,whereyourinformationwillbecheckedandpostedontheerratapageorusedinsubsequenteditionsofthebook.
Youcanviewerratafromthebook'sdetailpage.
韩国服务器怎么样?韩国云服务器租用推荐?韩国服务器距离中国近,有天然的地域优势,韩国服务器速度快而且非常稳定!有不少有亚洲市场的外贸公司选择韩国服务器开拓业务,韩国服务器因自身的优势也受到不少用户的青睐。目前的IDC市场上,韩国、香港、美国三个地方的服务器几乎占据了海外服务器的百分之九十以上。韩国服务器相比美国服务器来说速度更快,而相比香港机房来说则带宽更充足,占用市场份额非常大。那么,韩国服务器...
以前我们在参与到云服务商促销活动的时候周期基本是一周时间,而如今我们会看到无论是云服务商还是电商活动基本上周期都要有超过一个月,所以我们有一些网友习惯在活动结束之前看看商家是不是有最后的促销活动吸引力的,比如有看到阿里云年中活动最后一周,如果我们有需要云服务器的可以看看。在前面的文章中(阿里云新人福利选择共享性N4云服务器年79.86元且送2月数据库),(LAOZUO.ORG)有提到阿里云今年的云...
搬瓦工最新优惠码优惠码:BWH3HYATVBJW,节约6.58%,全场通用!搬瓦工关闭香港 PCCW 机房通知下面提炼一下邮件的关键信息,原文在最后面。香港 CN2 GIA 机房自从 2020 年上线以来,网络性能大幅提升,所有新订单都默认部署在香港 CN2 GIA 机房;目前可以免费迁移到香港 CN2 GIA 机房,在 KiwiVM 控制面板选择 HKHK_8 机房进行迁移即可,迁移会改变 IP...
selectedindexchanged为你推荐
cornerradius如何给TextView加个圆角?易pc华硕的易PC怎么样,能流畅运行的游戏大概是什么水平的?96155北京住房公积金电话96155经常没人接?人人时光机寻时光机歌词网站运营一般网站如何运营mate8价格华为mate8 128g售价多少钱bt封杀为什么现在网上许多BT下载都被封了?linux虚拟机怎么样在Linux下安装虚拟机首页无法修改主页无法更改怎么办2018最火爆的歌曲2018年热门歌曲谁有?
青岛虚拟主机 到期域名查询 泛域名绑定 linode seovip 美国十次啦服务器 网站cdn加速 什么是服务器托管 hktv 厦门电信 创建邮箱 太原联通测速 英雄联盟台服官网 德讯 永久免费空间 买空间网 .htaccess web是什么意思 大硬盘补丁 泥瓦工 更多