ASP.NET, the next version of ASP, is a programming framework se! to "reate
enterprise#"$ass We% App$i"ations. These app$i"ations are a""essi%$e on a g$o%a$ %asis $ea!ing to effe"ient information managment. The a!vantages ASP.NET offers is more than &st the next version of ASP. Why ASP.NET? ' Sin"e 1((), *i"rosoft has %een "onstant$+ working to shift it,s fo"s from Win!ows#%ase! p$atforms to the -nternet. As a res$t, *i"rosoft intro!"e! ASP .A"tive Server Pages) in Novem%er 1((/. ASP offere! the effi"ien"+ of -SAP- app$i"ations a$ong with a new $eve$ of simp$i"it+ that ma!e it eas+ to n!erstan! an! se. 0owever, ASP s"ript was an interprete! s"ript an! "onsiste! nstr"tre! "o!e an! was !iffi"$t to !e%g an! maintain. As the we% "onsists of man+ !ifferent te"hno$ogies, software integration for We% !eve$opment was "omp$i"ate! an! re'ire! to n!erstan! man+ !ifferent te"hno$ogies. A$so, as app$i"ations grew %igger in si1e an! %e"ame more "omp$ex, the nm%er of $ines of sor"e "o!e in ASP app$i"ations in"rease! !ramati"a$$+ an! was har! to maintain. Therefore, an ar"hite"tre was nee!e! that wo$! a$$ow !eve$opment of We% app$i"ations in a str"tre! an! "onsistent wa+. The .NET 2ramework was intro!"e! with a vision to "reate g$o%a$$+ !istri%te! software with -nternet fn"tiona$it+ an! interopera%i$it+. The .NET 2ramework "onsists of man+ "$ass $i%raries, in"$!es m$tip$e $angage spport an! a "ommon exe"tion p$atform. -t,s a ver+ f$exi%$e fon!ation on whi"h man+ !ifferent t+pes of top "$ass app$i"ations "an %e !eve$ope! that !o !ifferent things. 3eve$oping -nternet app$i"ations with the .NET 2ramework is ver+ eas+. ASP.NET is %i$t into this framework, we "an "reate ASP.NET app$i"ations sing an+ of the %i$t#in $angages. 4n$ike ASP, ASP.NET ses the 5ommon 6angage 7ntime .567) provi!e! %+ the .NET 2ramework. This 567 manages exe"tion of the "o!e we write. ASP.NET "o!e is a "ompi$e! 567 "o!e instea! of interprete! "o!e .ASP). 567 a$so a$$ows o%&e"ts written in !ifferent $angages to intera"t with ea"h other. The 567 makes !eve$opement of We% app$i"ations simp$e. Advantages Using ASP.NET ASP.NET !rasti"a$$+ re!"es the amont of "o!e re'ire! to %i$! $arge app$i"ations ASP.NET makes !eve$opment simp$er an! easier to maintain with an event#!riven, server#si!e programming mo!e$ ASP.NET pages are eas+ to write an! maintain %e"ase the sor"e "o!e an! 0T*6 are together The sor"e "o!e is exe"te! on the server. The pages have $ots of power an! f$exi%i$it+ %+ this approa"h The sor"e "o!e is "ompi$e! the first time the page is re'este!. Exe"tion is fast as the We% Server "ompi$es the page the first time it is re'este!. The server saves the "ompi$e! version of the page for se next time the page is re'este! The 0T*6 pro!"e! %+ the ASP.NET page is sent %a"k to the %rowser. The app$i"ation sor"e "o!e +o write is not sent an! is not easi$+ sto$en ASP.NET makes for eas+ !ep$o+ment. There is no nee! to register "omponents %e"ase the "onfigration information is %i$t#in The We% server "ontinos$+ monitors the pages, "omponents an! app$i"ations rnning on it. -f it noti"ies memor+ $eaks, infinite $oops, other i$$ega$ software or a"tivities, it seam$ess$+ ki$$s those a"tivities an! restarts itse$f ASP.NET va$i!ates information .va$i!ation "ontro$s) entere! %+ the ser withot writing a sing$e $ine of "o!e ASP.NET easi$+ works with A38 .NET sing !ata#%in!ing an! page formatting featres ASP.NET app$i"ations rn fater an! "onters $arge vo$mes of sers withot performan"e pro%$ems Q9) 3ifferen"e %:w Asp an! Asp.Net Non#*S P$atform Spport 5$assi"a$ ASP ha! no me"hanism of rnning itse$f on non# *i"rosoft te"hno$og+ p$atforms $ike the ,The Apa"he We% Server, ;t, ASP.NET ASP.NET "o$! %e rn on non#*i"rosoft P$atforms a$so. Cassini is a samp$e We% server pro!"e! %+ *i"rosoft whi"h, among other pro&e"ts, has %een se! to host ASP.NET with Apache. *$ti 6angage Spport in We%Page -n ASP on$+ two $angages were avai$a%$e for s"ripting <;S"ript an! =s"ript:=avas"ript. ;t in ASP.NET We are no $onger "onstraine! to the two s"ripting $angages avai$a%$e in tra!itiona$ ASP> An+ f$$+ "omp$iant .NET $angage "an now %e se! with ASP.NET, in"$!ing 5? an! <;.NET. Note ># .5? an! <;.Net are %oth server Si!e $angages.) Q9) Events of We% 2orm. 1. Page.8nPre-nit 9. *asterPage5ontro$.8n-nit .for ea"h "ontro$ on the master page) @. 5ontro$.8n-nit .for ea"h "onto$ on the page) A. *asterPage.8n-nit ). Page.8n-nit /. Page.8n-nit5omp$ete B. Page.6oa!PageState2romPersisten"e*e!im C. Page.6oa!<iewState (. *asterPage.6oa!<iewState 1D. Page.8nPre6oa! 11. Page.8n6oa! 19. *asterPage.8n6oa! 1@. *asterPage5ontro$.8n6oa! .for ea"h "ontro$ on the master page) 1A. 5ontro$.8n6oa! .for ea"h "ontro$ on the page) 1). 8nEEE ."ontro$ event) 1/. Page.8n6oa!5omp$ete 1B. Page.8nPre7en!er 1C. *asterPage.8nPre7en!er 1(. *asterPage5ontro$.8nPre7en!er .for ea"h "ontro$ on the master page) 9D. 5ontro$.8nPre7en!er .for ea"h "ontro$ on the page) 91. Page.8nPre7en!er5omp$ete 99. *asterPage5ontro$.Save5ontro$State .for ea"h "ontro$ on the master page) 9@. 5ontro$.Save5ontro$State .for ea"h "ontro$ on the page) 9A. Page.Save<iewState 9). *asterPage.Save<iewState 9/. Page.SavePageStateToPersisten"e*e!im 9B. Page.8nSaveState5omp$ete 9C. *asterPage5ontro$.8n4n$oa! .for ea"h "ontro$ on the master page) 9(. 5ontro$.8n4n$oa! .for ea"h "ontro$ on the page) @D. *asterPage.8n4n$oa! @1. Page.8n4n$oa! Web Form Events 2rom the moment a ser first re'ests an ASP.NET We% 2orm to the moment the server a"ta$$+ sen!s the response, 'ite a few events an! pro"esses o""r. A few of the most important ones are !es"ri%e! in the fo$$owing se"tions. A signifi"ant nm%er of events o""r %etween the moment a "$ient isses a page re'est an! the moment that the server sen!s the response. *an+ of these events wi$$ %e transparent to +o as the !eve$oper, an! the+ wi$$ invo$ve the "ompi$er, the prepro"essors, an! the varios "o$$e"tions that make p the .NET framework. 0owever, +o wi$$ nee! to n!erstan! some events %e"ase +o wi$$ $ike$+ "ome a"ross them in +or "o!ing es"apa!es. 2igre @.1 shows the events in a $ife "+"$e of an ASP.NET re'est. Figure .! Q) What are the Events? o""r %etween the moment a "$ient isses a page re'est an! the moment that the server sen!s the response. That is known as events. QA) "Practica#$ 5reate A 0T*6 An! Asp Page an! Perform the 5$ient Si!e an! Server Si!e Te"hno$og+. The we% server is not on$+ responsi%$e for pro"essing 0T*6 tags %t a$so the ASP s"ripts. The ASP engine, insta$$e! on the we% server, is responsi%$e for pro"essing ASP s"ripts. ;e"ase the %rowser "an on$+ !isp$a+ 0T*6 "ompati%$e text, it is the responsi%i$it+ of ASP engine to pro"ess the ASP s"ripts an! sen! the res$ts %a"k as 0T*6 text to the "$ient. -n other wor!s, the We% server sen!s 0T*6 text, part of whi"h ma+ %e the res$t of the ASP s"ripts. Fo might %e thinking how the We% server "an !etermine whether to "a$$ ASP engine or not. Fo sho$! re"a$$ from +or 0T*6 experien"e that 0T*6 fi$es have the .htm$ or .htm extension. Simi$ar$+, .asp extension is se! for ASP s"ripts. An .asp fi$e extension in!i"ates to the We% server to "a$$ the ASP engine. 0T*6 tags insi!e an ASP fi$e are pro"esse! %+ the ASP engineG however, an htm$ fi$e .meaning a fi$e that en!s with .htm or .htm$) "ontaining ASP "o!e won,t rn the ASP "o!eH 8n"e the We% server sen!s the res$ts to the "$ient, it is the "$ient,s %rowser responsi%i$it+ to !isp$a+ 0T*6 text. Again, the "$ient,s %rowser on$+ re"eives 0T*6 text. This "an %e "onfirme!, for an asp fi$e, %+ viewing the sor"e "o!e in the %rowser win!ow. Note server#si!e s"ripts are pro"esse! %efore a page is !own$oa!e! on a %rowser, an! "$ient#si!e s"ripts are pro"esse! after a page has %een !own$oa!e!. When we are writing ASP s"ripts, we are writing pages for server# si!e pro"essing. Ta%$e 1 smmari1es the !ifferen"es %etween "$ient an! server si!e s"ripting. Tab#e ! % Summary o& C#ient%side and Server%side Scripting 5$ient#si!e S"ripting -t is the "$ient,s responsi%i$it+ to pro"ess c#ient%side scripts. The "$ient#si!e s"ripts are not pro"esse! %+ the We%#server. 5$ient#si!e s"ripts are pro"esse! a&ter a We% page has %een !own$oa!e! onto the %rowser. 5$ient#si!e s"ripting is sef$ for va$i!ating ser,s inpt. Server#si!e S"ripting A we% server is responsi%$e for pro"essing ASP scripts an! retrning otpt to the "$ient. The server#si!e s"ripting is !one be&ore a page is !own$oa!e! on the %rowser. ASP s"ripts is a server#si!e te"hno$og+. The fo$$owing provi!es a %reif smmar+ of the steps invo$ve! in pro"essing ASP fi$es> 1. A we% %rowser re'ests an ASP fi$e 9. The we% server re"ives the re'est an! $oa!s the ASP fi$e. @. The server exe"tes the "o!e insi!e the ASP fi$e. An+ otpt from this pro"esse! ASP "o!e is sent to the %rowser in 0T*6 format, a$ong with an+ other 0T*6 "ontent. ;e"ase A"tive Server Pages is a server#si!e te"hno$og+, it offers nm%er of nota%$e a!vantages> ASP "o!e remains on the server. ;e"ase ASP "o!e !oes not $eave the server, the ser !oes not $earn a%ot how the page is %i$t. This provi!es a measre of se"rit+ of +or ASP "o!e an! other fi$es se! in "on&n"tion with +or ASP "o!e.