Modulo web

Introductio

WebFormsisoneofthreeprogrammingmodelsforcreatingASP.NETwebsitesandWebapplications.

TheothertwoprogrammingmodesareWebPagesandMVC(ModelViewController).

WebFormsistheoldestASP.NETprogrammingmodel.Itisanevent-activenwebpage quod integraatHTML, servientes, et servo code.

WebFormsiscompiledandexecutedontheserver,andthentheservergeneratesHTMLanddisplaysitasawebpage.

WebFormshashundredsofWebcontrolsandWebcomponentsusedtocreateuser-drivenwebsiteswithdataaccess.

Features

BasedonMicrosoftASP.NETtechnology.Inthistechnology,thecoderunningontheserverdynamicallygeneratesWebpageoutputtothebrowserorclientdevice.FormoreinformationaboutASP.NET,pleaserefertoASP.NETTechnicalBackgroundIntroductio.

  • Compatiblewithallbrowsersormobiledevices.TheWebFormspageautomaticallyrendersthecorrectHTMLthatconformstothebrowserforthestyle,layout,andotherfunctions.Inaddition,youcanalsochoosetodesigntheWebFormspagetorunonaspecificbrowser(suchasMicrosoftInternetExplorer5)andtakeadvantageofthefeaturesofthemulti-stylebrowserclient.Web form

  • Compatiblewithanylanguagesupportedbythe.NETcommonlanguageruntime,includingMicrosoftVisualBasic,MicrosoftVisualC#andMicrosoftJScript.NET.

  • BasedonMicrosoft.NETFramework.Itprovidesalltheadvantagesoftheframework,includinghostingenvironment,typesafetyandinheritance.

  • InVisualStudio,itissupportedbypowerfulrapidapplicationdevelopment(RAD)tools,whichareusedtodesignandprogramforms.

  • ItcanbeextendedwithcontrolsthatprovideRADfunctionsforWebdevelopment,allowingyoutoquicklycreatemulti-styleuserinterfaces.

  • Beflexiblebecauseyoucanadduser-createdcontrolsandthird-partycontrolstothem.

Components

IntheWebformpage,userinterfaceprogrammingisdividedintotwodifferentparts:visualcomponentsandlogic.IfyouhaveusedtoolslikeVisualBasicandVisualC++before,youwillagreethatthereissuchadivisionbetweenthevisualpartoftheformandthecodethatinteractswithitbehindtheform.

ThevisualelementiscalledtheWebform"page"(page).ThistypeofpageconsistsofafilecontainingstaticHTMLand/orASP.NETservercontrols.

Webformpagesareusedascontainersforstatictextandcontrolstobedisplayed.UsingtheVisualStudioWebFormDesignerandASP.NETservercontrols,youcandesigntheformthewayyouwouldinanyVisualStudioapplication.Formoreinformation,seeControlsavailableonWebFormspages.

Thelogicofawebformpage consistsofcode, quod creatur per youto interact with the form. Programminglogicislocatedina filedifferent a theuserinterfacefile. This fileis calleda "code-post" fileandhasanextensionof".aspx.vb" vel".

Filestructure

Thecode-behindfilesofallWebFormspagesintheprojectarecompiledintoprojectdynamiclinklibrary(.dll)files.The.aspxpagefilewillalsobecompiled,butthecompilationmethodisslightlydifferent.Whenauserbrowsestoan.aspxpageforthefirsttime,ASP.NETautomaticallygeneratesa.NETclassfilethatrepresentsthepageandcompilesitintoanother.dllfile.Theclassgeneratedforthe.aspxpageinheritsfromthecode-behindclassthatiscompiledintotheproject's.dllfile.WhenauserrequeststheURLofaWebpage,the.dllfilewillrunontheserveranddynamicallygenerateHTMLoutputforyourpage.Formoreinformation,seeWebFormsPageHandling.

FormoreinformationonhowtoconstructaWebFormspage,seeWebFormsCodeModel.

WhattasksdoestheWebFormspagehelpyouaccomplish?

Webapplicationprogrammingbringssomespecialproblems.Whenprogrammingtraditionalclient-basedapplications,youusuallydon’tWillencountertheseproblems.Thesechallengesinclude:

  • Implementamulti-styleWebuserinterface.Forauserinterfacewithacomplexlayoutandalargeamountofdynamiccontentandfull-featureduserinteractionobjects,itwillbedifficultandlaborioustousebasicHTMLfunctionstodesignandimplement.Particularlydifficultistocreatemulti-styleuserinterfacesforapplicationsthatmayrunonmultipledifferentbrowsersandclientdeviceplatforms.

  • Theseparationofclientandserver.InaWebapplication,theclient(browser)andtheserveraredifferentprograms,andtheyusuallyrunondifferentcomputers(evenondifferentoperatingsystems).Therefore,thetwopartsthattogethermakeuptheapplicationshareverylittleinformation;theycancommunicate,butusuallyonlyexchangesmallpiecesofsimpleinformation.

  • Statelessexecution.Whenawebserverreceivesarequestforapage,itwillfindthepage,processit,sendittothebrowser,anddiscardallpageinformation.Iftheuserrequeststhesamepageagain,theserverrepeatstheentireprocess:reprocessingthepagefromthebeginning.Inotherwords,theserverwillnotrememberthepagesithasprocessed.Therefore,iftheapplicationneedstomaintaininformationaboutacertainpage,thisbecomesaproblemthatmustbesolvedintheapplicationcode.

  • Unknownclientfunction.Inmanycases,webapplicationscanbeaccessedbymultipleusersusingdifferentbrowsers.Browsershavedifferentfunctions,soitisdifficulttocreateanapplicationthatwillworkequallywellonallbrowsers.

  • Thecomplexityofdataaccess.Readingandwritingdatasourceslocatedintraditionalwebapplicationscanbecomplicatedandconsumealotofresources.

  • Complexityinscalability.Inmanycases,duetothelackofcompatibilitybetweendifferentcomponentsoftheapplication,Webapplicationsdesignedwithexistingmethodsfailtoachievethegoalofscalability.Forapplicationswithashortdevelopmentcycle,thisisoftentheonlyplacethatwillleadtofailure.

Tosolvethesewebapplicationproblems,itmaytakealotoftimeandeffort.WebformpagesandASP.NETpageframeworksdealwiththeseproblemsthroughthefollowingaspects:

  • Intuitiveandconsistentobjectmodel.TheASP.NETpageframeworkprovidesanobjectmodelthatenablesyoutotreattheformasawhole,ratherthanseparateclientandservermodules.Inthismodel,youcanprogramtheforminamoreintuitivewaythaninatraditionalWebapplication,includingtheabilitytosetthepropertiesoftheformelementsandrespondtoevents.Inaddition,ASP.NETservercontrolsareanabstractmodelbasedonthephysicalcontentoftheHTMLpageandthedirectinteractionbetweenthebrowserandtheserver.Generally,youcanuseservercontrolsinthesamewaythatyouusecontrolsinclientapplications,regardlessofhowtocreateHTMLtodisplayandprocessthecontrolsandtheircontents.

  • Event-drivenprogrammingmodel.TheWebFormspagebringsafamiliareventhandlerwritingmodeltoWebapplications,whichisusedtowriteeventhandlersforeventsthatoccurontheclientorserver.TheASP.NETpageframeworkabstractsthismodelsothatthebasicmechanismsforcapturingeventsontheclient,transmittingthemtotheserver,andinvokingappropriatemethodsareallautomaticandinvisibletotheimplementer.Thisresultsinaclear,easy-to-writecodestructurethatsupportsevent-drivendevelopment.

  • Intuitivestatusmanagement.TheASP.NETpageframeworkautomaticallyhandlesthestatemaintenancetasksoftheformanditscontrols.Itenablesyoutomaintainthestateofapplication-specificinformationinanexplicitway.Thisstatemanagementcanbeachievedwithoutusingalargeamountofserverresources,andcanbeachievedbysendingacookietothebrowserornotbysendingacookietothebrowser.

  • Abrowser-independentapplication.TheASP.NETpageframeworksupportsthecreationofallapplicationlogicontheserver,eliminatingtheneedforyoutoexplicitlycodefordifferencesinbrowsers.However,itstillallowsyoutoautomaticallytakeadvantageofbrowser-specificfeaturesbywritingclientcodetoprovideenhancedperformanceandaricherclientexperience.

  • .NETFrameworkcommonlanguageruntimesupport.ASP.NETpageframeisatechnologyofASP.NET.ASP.NETisbasedonthe.NETFramework,sotheentireframeworkcanbeusedinanyASP.NETapplication.Youcanuseanylanguagecompatiblewiththeruntime(includingMicrosoftVisualBasic,VisualC#,andJScript.NET)toauthorapplications.Inaddition,dataaccessissimplifiedthroughthedataaccessinfrastructureprovidedbythe.NETFramework(includingADO.NET).

  • .NETFrameworkcanscaleserverperformance.TheASP.NETpageframeworkenablesyoutoeffectivelyscaleaWebapplicationfromacomputerwithonlyoneprocessortoamulti-computer"Webfarm"withouttheneedforthelogicoftheapplicationComplexchanges.

Related Articles
TOP