版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、東北石油大學(xué)本科畢業(yè)設(shè)計(jì)英文文獻(xiàn)及翻譯學(xué)院計(jì)算機(jī)與信息技術(shù)學(xué)院班級(jí)07-1 班學(xué)號(hào)姓名指導(dǎo)教師職稱(chēng)副教授 鍵入文字 10ASP.NET 技術(shù)ASP.NET 頁(yè)面ASP.NET 和ASP.NET構(gòu)造ASP.NET 是微軟.NET framework整體的一局部, 它包含一組大量的, 你如何學(xué)會(huì)ASP.NET 很適合的放在.NET framework, 和學(xué)會(huì)能在你的 ASP.NET 頁(yè)面中使用語(yǔ)言。.NET類(lèi)庫(kù)假想你是微軟。 假想你必需支持大量的編程語(yǔ)言-比方 Visual 語(yǔ)言的很多功能具有重疊性。舉例來(lái)說(shuō),對(duì)于每一種語(yǔ)言,你必需包括存取文件系統(tǒng)、與數(shù)據(jù)庫(kù)協(xié)同工作和操作字符串的方法。,舉例來(lái)說(shuō)
2、,都能夠Visual Basic 寫(xiě)的條件語(yǔ)句的語(yǔ)法不C+ 寫(xiě)的不一樣,程序的功能也是一樣的。值和最小值可能依靠語(yǔ)言的種類(lèi),但是根本的數(shù)據(jù)類(lèi)型是一樣的。創(chuàng)輪子? 對(duì)全部的語(yǔ)言創(chuàng)立這種功能一次,然后把這個(gè)功能用在每一種語(yǔ)言中豈不是更簡(jiǎn)潔。.NET說(shuō),.NET類(lèi)庫(kù)包含處理數(shù)據(jù)庫(kù)訪問(wèn)的類(lèi)和文件協(xié)同工作,操作文本和生Web協(xié)議。.NET framewor字符串、整型、字節(jié)型、字符型和數(shù)組。最重要地, 寫(xiě)這一本書(shū)的目的, .NET類(lèi)庫(kù)包含構(gòu)建的 ASP.NET 頁(yè)面的類(lèi)。然而你需要了解當(dāng)你構(gòu)建 .NET頁(yè)面的時(shí)候能夠訪問(wèn) .NETframework 的任意類(lèi)。理解命名空間正如你猜測(cè)的, .NET fra
3、mework(超3,400) 。幸運(yùn)地,類(lèi)不是簡(jiǎn)潔的堆在一起。.NETframework的類(lèi)被組織成有層次構(gòu)造的命名空間。ASP Classic Note在從前的ASP中,你僅僅能夠訪問(wèn)五個(gè)標(biāo)準(zhǔn)類(lèi)。相比之下 ASP.NET供給超過(guò) 3,400個(gè)類(lèi)!一個(gè)命名空間包含一組規(guī)律的類(lèi)。舉例來(lái)說(shuō),涉及到與文件系統(tǒng)協(xié)同工作的類(lèi)就集合在System.IO 命名空間中。命名空間被組織成一個(gè)層次構(gòu)造(一棵規(guī)律樹(shù)) SYSTEM 命名空間。這個(gè)命名空間包含根本的數(shù)據(jù)類(lèi)型的全部的類(lèi),數(shù)組,還包含供給隨機(jī)數(shù)字和日期的類(lèi)。你通過(guò)完整的類(lèi)的命名空間能唯一識(shí)別任何的類(lèi)在.NET framework中的位置。 舉例來(lái)說(shuō),指定
4、找到一個(gè)the File class 類(lèi),按如下操:System.IO.文件System.IO指命名空間 ,而文件指定特定的類(lèi)。提示你能夠掃瞄.NET Framework全部的標(biāo)準(zhǔn)類(lèi)的命名空間。通過(guò) .NETFramework 的參考文檔可以掃瞄類(lèi)庫(kù)。ASP.NET 命名空間在默認(rèn)狀況下,在你的ASP.NET頁(yè)面中,類(lèi)被包含在一個(gè)選定的命名空間中這些默認(rèn)的命名空間使你在ASP.NET中最常用到的。System 命名空間- 包含全部的根本數(shù)據(jù)類(lèi)型和其他有用的類(lèi),例如:那些關(guān)于產(chǎn)生隨機(jī)數(shù)字和日期的類(lèi)。System.Collections命名空間- 包含的類(lèi)是標(biāo)準(zhǔn)的集合類(lèi),例如:哈希表,數(shù)組列表。S
5、ystem.Collections.Specialized 命名空間- 連接列表和字符串集合。System.Configuration 命名空間- 包括Web.config files類(lèi)。System.Text命名空間-包含編碼,解碼和操作字符串內(nèi)容的類(lèi)。System.Text.RegularExpressions命名空間- 包含的是匹配正則表達(dá)式和替代操作類(lèi)。System.Web 命名空間-工作在萬(wàn)維網(wǎng)方面包含的是掃瞄器懇求和效勞器響應(yīng)的類(lèi)。System.Web.Caching 命名空間- 包含頁(yè)面緩沖內(nèi)容和自定義緩沖操作的類(lèi)。System.Web.Security命名空間- 密碼驗(yàn)證的類(lèi)。
6、System.Web.SessionState命名空間- 包含執(zhí)行保存狀態(tài)的類(lèi)。System.Web.UI命名空間- 包含構(gòu)建 ASP.NET 頁(yè)面的用戶(hù)接口的類(lèi)。System.Web.UI.HTMLControls命名空間- 包含 HTML 控件的類(lèi)。System.Web.UI.WebControls命名空間- 包含Web控件的類(lèi)。.NET Framework -可用的語(yǔ)言這一本書(shū)的目的, 你將會(huì)為以 Visual Basic 作為你的編程語(yǔ)言來(lái)完成你的 ASP.NET ASP.NET 頁(yè)面的默認(rèn)語(yǔ)言。雖然你在這一本書(shū)中始終用 Visual Basic, 但是,你也需要了解用其它的支持公共語(yǔ)
7、言庫(kù)的語(yǔ)言創(chuàng)立ASP.NET頁(yè)面。除此之外, 這包括 C#,JScript.NET和C+ 。提示C# 源代碼。除微軟之外的公司產(chǎn)生的幾十個(gè)其他的語(yǔ)言已經(jīng)能夠和.NET frameworkPythonSmallTalk 、Eiffel和 COBOL。這就意味著假設(shè)你真的想 , 你可以使用 COBOL 寫(xiě)ASP.NET 頁(yè)面。不管你使用什么語(yǔ)言開(kāi)發(fā) ASP.NET 頁(yè)面,你需要明白ASP.NET在執(zhí)行前必需編譯,這就意味著ASP.NET執(zhí)行速度格外快。你第一次懇求 ASP.NET 頁(yè)面, 頁(yè)面被編譯成一個(gè).NET類(lèi), 這個(gè)類(lèi)Temporary ASP.NETFilesASP.NET頁(yè)面一個(gè)通信類(lèi)文
8、件消滅在Temporary ASP.NETFilesASP.NET頁(yè)面,那個(gè)通信類(lèi)文件就會(huì)執(zhí)行。當(dāng) ASP.NET 頁(yè)面被編譯的時(shí)候,它沒(méi)被直接地被編譯成機(jī)器碼而(MSIL)全部.NET可用的語(yǔ)言都被編譯成這種中間語(yǔ)言。一個(gè)ASP.NET 頁(yè)面不會(huì)被編譯本錢(qián)地機(jī)器碼直到它被一個(gè)掃瞄器訪問(wèn),在那個(gè)時(shí)間點(diǎn)包含在Temporary ASP.NET Files名目下的類(lèi)文件用JIT編譯器編譯并且執(zhí)行。這些迷惑的方面表達(dá)在整個(gè)過(guò)程都在后臺(tái)運(yùn)行,你必需要做的是用資源代碼為你的ASP.NET頁(yè)面創(chuàng)立一個(gè)文本文件。.NETframework 為你處理完轉(zhuǎn)換它為編譯碼這一困難工作。典型ASP提示VBScript
9、 怎么樣呢? 在 ASP.NET 之前, VBScript 是開(kāi)發(fā)動(dòng)態(tài)頁(yè)面最流行的語(yǔ)言。ASP.NET 不支持VBScript ,而且這是好消息。 Visual Basic 是一個(gè) VBScript 的超集,意味著 Visual Basic 相對(duì)于 VBScript有更多的功能。 因此, 你用 Visual Basic 有更豐富的函數(shù)和語(yǔ)句供你使用。此外,不像 VBScript , Visual Basic Visual Basic VBScript代碼感覺(jué)會(huì)更簡(jiǎn)潔一些。假設(shè)你過(guò)去只用VBScript而不用 Visual Basic,也不用擔(dān)憂。 由于VBScript 如此接近 Visual
10、Basic, 你將會(huì)覺(jué)察在這二種語(yǔ)言之間的轉(zhuǎn)變是很簡(jiǎn)潔的。提示在.NET frameworkIL Disassembler的好玩的工具。在臨時(shí)的ASP.NET文件名目中你能使用這個(gè)工具查看沒(méi)有裝配的ASP.NET 類(lèi)的代碼。 它列出了類(lèi)的全部方法和屬性使你能夠掃瞄中間代碼。ASP.NETIL Disassembler TextBox 控件的中間代碼。(位于在System.Web.dll 的文件中)介紹 ASP.NET 控件ASP.NET 控件為你的Web應(yīng)用程序供給動(dòng)態(tài)和交互的用戶(hù)接口。這建立 HTML 窗體元素,交互式日歷, 而且可以滾動(dòng)標(biāo)題廣告。ASP.NET 控件和 HTML 內(nèi)容共存。
11、 典型地,你用通常的 HTMLASP.NET 控件創(chuàng)立網(wǎng)頁(yè)的動(dòng)態(tài)區(qū)域。了解 ASP.NET 控件是怎么工作的?最好的方法是看一個(gè)簡(jiǎn)潔的Web應(yīng)用窗體頁(yè)面。添加ASP.NET頁(yè)面的代碼其次個(gè)難點(diǎn)就是ASP.NET頁(yè)面的代碼,他是準(zhǔn)確的頁(yè)面的程序代碼,在你添加的程序用戶(hù)處理控件也頁(yè)面大事。HTML窗體中的Button按鈕就會(huì)響應(yīng)一個(gè)大事 (單擊大事) 。 典型地,你想添加代碼響應(yīng)這個(gè)大事到頁(yè)面中。 舉例來(lái)說(shuō),當(dāng)某人單擊Button按鈕控件的時(shí)候,你可以保存窗體數(shù)據(jù)到一個(gè)文件或者數(shù)據(jù)庫(kù)??丶皇俏ㄒ坏哪芟鄳?yīng)大事的事物。當(dāng)它被懇求的時(shí)候一個(gè)ASP.NET 頁(yè)面每次都能夠響應(yīng)幾個(gè)大事。 舉例來(lái)說(shuō),每當(dāng)你
12、懇求一個(gè)頁(yè)面,頁(yè)面的初始化大事就會(huì)被觸發(fā)。每當(dāng)時(shí)始化大事發(fā)生的時(shí)候,你能夠添加代碼到頁(yè)面中來(lái)執(zhí)行。Web 效勞器控件創(chuàng)立窗體構(gòu)建機(jī)敏窗體你用幾個(gè)根本W(wǎng)eb控件來(lái)代替標(biāo)準(zhǔn)的 HTML 窗體元素,例如radiobuttonstext boxes, and list boxes. 你能夠用這些控件為你的Web應(yīng)用程序在你的ASP.NETWeb控件供給了具體的提綱和程序源代碼。把握頁(yè)面掃瞄ASP.NET頁(yè)面轉(zhuǎn)HTML窗體鏈接到另一個(gè)頁(yè)面來(lái)方法自動(dòng)讓一個(gè)用戶(hù)掃瞄一個(gè)的頁(yè)面。 最終,你學(xué)會(huì)用超級(jí)鏈接控件怎么把頁(yè)面連在一起。對(duì)控件應(yīng)用格式Web你掃瞄一下針對(duì)全部Web控件格式屬性他們是根本控件類(lèi)的格式屬性。
13、然后,你學(xué)會(huì)在Web控件上應(yīng)用樣式表風(fēng)格。用驗(yàn)證控件做頁(yè)面驗(yàn)證使用客戶(hù)端驗(yàn)證傳統(tǒng)地,當(dāng)增加驗(yàn)證到他們的頁(yè)面中時(shí),他們會(huì)面臨一個(gè)嚴(yán)峻的選證規(guī)章到你的客戶(hù)端代碼。來(lái)說(shuō),一個(gè)使用者無(wú)視在一個(gè)要求檢驗(yàn)的字段中輸入一個(gè)值,你能夠準(zhǔn)時(shí)的顯示一個(gè)錯(cuò)誤信息而不需要返回到效勞器端解決。人們寵愛(ài)客戶(hù)端的驗(yàn)證。 它看起來(lái)很棒而且產(chǎn)生一種比較好的效果。 然而,問(wèn)題是它不與全部的掃瞄器兼容。 不是全部的掃瞄器支持證沒(méi)有保障。由于這個(gè)緣由,很多開(kāi)發(fā)者在過(guò)去打算添加自定義驗(yàn)證到效勞器端。由于效勞器端代碼能夠和任何掃瞄器協(xié)同工作。就這樣的做法更有安全 的保障。器有力量支持JavaScript JavaScript,那個(gè)驗(yàn)證規(guī)
14、章會(huì)自動(dòng)在效勞器端代碼中執(zhí)行。然而你需要留意的是,客戶(hù)端的驗(yàn)證僅僅能夠工作在IE4.0或更高的中運(yùn)行。把握字段: RequiredFieldValidator 控件Web窗體中是否為空, 典型地,你和TextBox 入型控件,例如:RadioButtonList.控件。驗(yàn)證表達(dá)式: RegularExpressionValidator 控件你能使用 RegularExpressionValidator 控件來(lái)驗(yàn)證輸入的值是否和輸入一個(gè)合法的電子郵件地址, 號(hào)碼,用戶(hù)名或密碼。怎樣用一個(gè)正則表達(dá)式來(lái)完成這些驗(yàn)證任務(wù)將會(huì)在下面的例子中一一列出。比較值: CompareValidator 控件這個(gè)C
15、ompareValidator 控件用于比較一個(gè)輸入的數(shù)據(jù)和另外一個(gè)值是否一樣。另外一個(gè)值可能是固定值,例如:一個(gè)特定的數(shù)字或者是輸入到另一個(gè)控件中的一個(gè)值??偨Y(jié)錯(cuò)誤: ValidationSummary 控件假想一個(gè)頁(yè)面有50個(gè)字段假設(shè)你僅僅用上局部爭(zhēng)辯的那些驗(yàn)證控件到第48個(gè)頁(yè)面字段來(lái)找到這個(gè)錯(cuò)誤信息。幸好,微軟除了包含上面提到的控件還包括 ValidationSummary 控任何一個(gè)地方。先進(jìn)的控件編程保存掃瞄狀態(tài)默認(rèn)地,幾乎全部的 ASP.NET 控件都會(huì)在從前的窗體中保存他們Lebel標(biāo)簽上然后提交那個(gè)頁(yè)面,當(dāng)那個(gè)頁(yè)面再次被訪問(wèn)那個(gè)Lebel標(biāo)簽的內(nèi)容將會(huì)被保存下來(lái)。其,它不依靠c
16、ookies, session變量、或應(yīng)用程序變量。 掃瞄狀態(tài)在一個(gè)名叫做VIEWSTATEWeb窗體。當(dāng)機(jī)敏的應(yīng)用時(shí), 掃瞄狀態(tài)能夠在你的網(wǎng)站中產(chǎn)生藝術(shù)性的和樂(lè)觀的效果,例如:假設(shè)你在一個(gè)支持掃瞄狀態(tài)的控件中顯示數(shù)據(jù)庫(kù)數(shù)據(jù),保存頁(yè)面里的數(shù)據(jù)狀態(tài)。顯示和隱蔽內(nèi)容制造一種在線納稅系統(tǒng),而且你想要顯示或者隱蔽一個(gè)包含適用于已婚的稅文件編檔員的問(wèn)題的局部。或者, 假想你想要添加一個(gè)幫助按鈕到網(wǎng)站上去。 你可能想要隱蔽或者顯示完成依靠用戶(hù)參考的問(wèn)題的具體說(shuō)明。最終,假想你想要把一個(gè)tax form 變成很多頁(yè)面,以便一個(gè)人每次只看那個(gè)tax form的一局部。在以下的局部中,你學(xué)會(huì)用屬性設(shè)置在一個(gè)窗體
17、中來(lái)隱蔽或顯示控Visible and Enabled屬性來(lái)隱蔽和顯示頁(yè)面內(nèi)容。使用Visible and Enabled屬性每個(gè)控件,包括 HTML 和Web控件,有一個(gè)Visible 屬性來(lái)打算那個(gè)控件是否可見(jiàn)。 當(dāng)一個(gè)控件的Visible是false值,那個(gè)控件就不會(huì)在頁(yè)面上顯示;那個(gè)控件也不會(huì)進(jìn)一步運(yùn)行。Web控件 (不是每個(gè)HTML 控件) 還有一個(gè)叫Enabled的屬性。當(dāng)Enabled的屬性是falseIE4.0或更高的版本那個(gè)控件被封住了,也不起作用了,當(dāng)用其他的掃瞄器的時(shí)候,如:網(wǎng)景掃瞄器那個(gè)控件不會(huì)被封,但它也是不起作用的。使掃瞄狀態(tài)失效ASP.NET頁(yè)面作為一個(gè)整體的掃瞄
18、狀態(tài)失效。 舉例來(lái)說(shuō), 你可能使用一個(gè)有包含很多數(shù)據(jù)的控件.(假想一個(gè)RadioButtonList 控件把握1,000 個(gè)選項(xiàng))假設(shè)你擔(dān)憂頁(yè)面數(shù)據(jù)會(huì)大大的降低頁(yè)面的顯示速度,你可能不想要加載數(shù)據(jù)到隱蔽的VIEWSTATE頁(yè)面字段。使用豐富頁(yè)面的控件在以下的局部中,你學(xué)會(huì)在ASP.NET Framework怎樣使用三種特征動(dòng)的廣告,HTMLInputFile控件來(lái)承受文件的上傳。ASP.NETTechniqueBuilding ASP.NET sASP.NET and the .NET FrameworkASP.NET is part of Microsoft”s overall .NET f
19、ramework, which containsa vast set of programming classes designed to satisfy any conceivableprogramming need. In the following two sections, you learn how ASP.NET fits within the .NET framework, and you learn about the languages you can use in your ASP.NET s.The.NETFrameworkClassLibraryImagine that
20、 you are Microsoft. Imagine that you have to supportmultiple programming languagessuch as Visual Basic, JScript, and C+. Agreat deal of the functionality of these programming languages overlaps. For example, for each language, you would have to include methods for accessingthe file system, working w
21、ith databases, and manipulating strings.Furthermore, these languages contain similar programming constructs.Every language, for example, can represent loops and conditionals. Eventhough the syntax of a conditional written in Visual Basic differs from thesyntax of a conditional written in C+, the pro
22、gramming function is the same.Finally, most programming languages have similar variabledata types.In most languages, you have some means of representing strings and integers,for example. The maximum and minimum size of an integer might depend onthe language, but the basic data type is the same.Maint
23、aining all this functionality for multiple languages requires a lot ofwork. Why keep reinventing the wheel? Wouldn”t it be easier to create all thisfunctionality once and use it for every language?The .NET Framework Class Library does exactly that. It consists of avast set of classes designed to sat
24、isfy any conceivable programming need. Forexample, the .NET framework contains classes for handling database access, working with the file system, manipulating text, and generating graphics. In addition, it contains more specialized classes for performing tasks such asworking with regular expression
25、s and handling network protocols.The .NET framework, furthermore, contains classes that represent all thebasic variable data types such as strings, integers, bytes, characters, andarrays.Most importantly, for purposes of this book, the .NET Framework Class LibrarycontainsclassesforbuildingASP.NETs.Y
26、ouneedunderstand, however, that you can access any of the .NET framework classes when you are building your ASP.NET s.Understanding NamespacesAs you might guess, the .NET framework is huge. It contains thousands of classes (over 3,400). Fortunately, the classes are not simply jumbledtogether. The cl
27、asses of the .NET framework are organized into a hierarchy ofnamespaces.ASP Classic NoteIn previous versions of Active Server s, you had access to only five standard classes (the Response, Request, Session, Application, and Serverobjects). ASP.NET, in contrast, provides you with access to over 3,400
28、classes!A namespace is a logical grouping of classes. For example, all theclasses that relate to working with the file system are gathered together into the System.IO namespace.The namespaces are organized into a hierarchy (a logical tree). At the root of the tree is the System namespace. This names
29、pace contains all the classes for the base data types, such as strings and arrays. It also contains classes for working with random numbers and dates and times.You can uniquely identify any class in the .NET framework by using thefull namespace of the class. For example,to uniquely refer to the clas
30、s that represents a file system file (the File class), you would use the following:System.IO.FileSystem.IO refers to the namespace, and File refers to the particular class.NOTEYou can view all the namespaces of the standard classes in the .NET Framework Class Library by viewing the Reference Documen
31、tation for the .NET Framework.Standard ASP.NET NamespacesThe classes contained in a select number of namespaces are available in yourASP.NETsbydefault.(Youmustexplicitlyimportnamespaces.) These default namespaces contain classes that you use mostoften in your ASP.NET applications:System Contains all
32、 the base data types and other useful classes such as those related to generating random numbers and working with dates andtimes.System.CollectionsContainsclassesforworkingwithstandardcollection types such as hash tables, and array lists.System.Collections.SpecializedContainsclassesthatrepresentspec
33、ialized collections such as linked lists and string collections.System.Configuration Contains classes for working with configurationfiles (Web.config files).System.TextContainsclassesforencoding,decoding,manipulating the contents of strings.System.Text.RegularExpressions Contains classes for perform
34、ingregular expression match and replace operations.System.Web Contains the basic classes for working with the World Wide Web, including classes for representing browser requests and server responses.System.Web.Caching Contains classes used for caching the content ofs and classes for performing custo
35、m caching operations.System.Web.Security Contains classes for implementing authentication and authorization such as Forms and Passport authentication.System.Web.SessionState Contains classes for implementing session state.System.Web.UI Contains the basic classes used in building the user interface o
36、f ASP.NET s.System.Web.UI.HTMLControls Contains the classes for the HTML controls.System.Web.UI.WebControls Contains the classes for the Webcontrols.NET Framework-Compatible LanguagesFor purposes of this book, you will write the application logic for your ASP.NET s using Visual Basic as your program
37、ming language. It is thedefault language for ASP.NET s. Although you stick to Visual Basic inthis book, you also need to understand that you can create ASP.NET s byusing any language that supports the .NET Common Language Runtime. Out of the box, this includes C#, JScript.NET, and the Managed Extens
38、ions toC+.NOTEThe CD included with this book contains C# versions of all the codesamples.Dozens of other languages created by companies other than Microsofthave been developed to work with the .NET framework. Some examples of these other languages include Python, SmallTalk, Eiffel, and COBOL. Thisme
39、ans that you could, if you really wanted to, write ASP.NET s usingCOBOL.Regardless of the language that you use to develop your ASP.NET s,you need to understand that ASP.NET s are compiled before they are executed. This means that ASP.NET s can execute very quickly.The first time you request an ASP.
40、NET , the is compiled intoa .NET class, and the resulting class file is saved beneath a special directoryon your server named Temporary ASP.NET Files. For each and everyASP.NET,acorrespondingclassfileappearsintheTemporaryASP.NET Files directory. Whenever you request the same ASP.NET in the future, t
41、he corresponding class file is executed.When an ASP.NET is compiled, it is not compiled directly into machine code. Instead, it is compiled into an intermediate-level language called Microsoft Intermediate Language (MSIL). All .NET-compatiblelanguages are compiled into this intermediate language.An
42、ASP.NET isn”t compiled into native machine code until it isactually requested by a browser. At that point, the class file contained in the Temporary ASP.NET Files directory is compiled with the .NET frameworkJust in Time (JIT) compiler and executed.The magical aspect of this whole process is that it
43、 happens automaticallyin the background. All you have to do is create a text file with the source codefor your ASP.NET , and the .NET framework handles all the hard work of converting it into compiled code for you.ASP CLASSIC NOTEWhat about VBScript? Before ASP.NET, VBScript was the most popular lan
44、guage for developing Active Server s.ASP.NET does not support VBScript, and this is good news. Visual Basic is a superset of VBScript, which means that Visual Basic has all the functionality of VBScript and more. So, you have a richer set of functions andstatements with Visual Basic.Furthermore, unl
45、ike VBScript, Visual Basic is a compiled language. Thismeans that if you use Visual Basic to rewrite the same code that you wrote with VBScript, you can get better performance.If you have worked only with VBScript and not Visual Basic in the past, don”t worry. Since VBScript is so closely related to
46、 Visual Basic, you”ll find iteasy to make the transition between the two languages.NOTEMicrosoftincludesaninterestingtoolnamedtheILDisassembler(ILDASM) with the .NETframework. You can use this tool to view thedisassembled code forany ofthe ASP.NET classes in the TemporaryASP.NET Files directory. It
47、lists all the methods and properties of the class and enables you to view the intermediate-level code.This tool also works with all the ASP.NET controls discussed in this chapter. For example, you can use the IL Disassembler to view the intermediate-level code for the TextBox control (located in a f
48、ile namedSystem.Web.dll).Introducing ASP.NET ControlsASP.NET controls provide the dynamic and interactive portions of theuser interface for your Web application. The controls render the content that the users of your Web site actually see and interact with. For example, youcan use controls to create
49、 HTML form elements, interactive calendars, and rotating banner advertisements.ASP.NET controls coexist peacefully with HTML content. Typically, you create the static areas of your Web s with normal HTML content andcreate the dynamic or interactive portions with ASP.NET controls.The best way to unde
50、rstand how ASP.NET controls work in an HTML is to look at a simple Web Forms .Adding Application Logic to an ASP.NET The second building block of an ASP.NET is the application logic,which is the actual programming code in the . You add application logicto a to handle both control and events.If a use
51、r clicks a Button control within an HTML form, for example, the Button control raises an event (the Click event). Typically, you want to add code to the that does something in response to this event. For example, when someone clicks the Button control, you might want to save the formdata to a file o
52、r database.Controls are not the only things that can raise events. An ASP.NET itself raises several events every time it is requested. For example, whenever you request a , the ”sLoad event is triggered. You can addapplication logic to the that executes whenever the Load event occurs.BuildingFormswi
53、thWebServerControlsBuildingSmartFormsYou use several of the basic Web controls to represent standard HTML form elements such as radio buttons, text boxes, and list boxes. You can use these controls in your ASP.NET s to create the user interface for yourWeb application. The following sections provide
54、 detailed overviews andprogramming samples for each of these Web controls.Controlling NavigationIn the following sections, you learn how to control how a user movesfrom one ASP.NET to another. First, you learn how to submit an HTMLform to another and retrieve form information. Next, you learn how to
55、 use the Redirect method to automatically transfer a user to a new .Finally, you learn how to link s together with the HyperLink control.Applying Formatting to ControlsIn the following sections, you learn how to make more attractive Webforms. First, you look at an overview of the formatting properti
56、es common to all Web controls; they are the formatting properties of the base control class.Next, you learn how to apply Cascading Style Sheet styles and classes to Webcontrols.PerformingFormValidationwithValidationControlsUsingClient-sideValidationTraditionally, Web developers have faced a tough ch
57、oice when addingform validation logic to their s. You can add form validation routines to your server-side code, or you can add the validation routines to yourclient-side code.The advantage of writing validation logic in client-side code is that you can provide instant feedback to your users. For ex
58、ample, if a user neglects to enter a value in a required form field, you can instantly display an errormessage without requiring a roundtrip back to the server.People really like client-side validation. It looks great and creates a betteroverall user experience. The problem, however, is that it does
59、 not work with all browsers. Not all browsers support JavaScript, and different versions ofbrowsers support different versions of JavaScript, so client-side validation is never guaranteed to work.For this reason, in the past, many developers decided to add all their form validation logic exclusively
60、 to server-side code. Because server-side code functions correctly with any browser, this course of action was safer.Fortunately, the Validation controls discussed in this chapter do not forceyou to make this difficult choice. The Validation controls automatically generate both client-side and serve
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 科技安全課件
- ttt講師培訓(xùn)課件
- 測(cè)量血壓培訓(xùn)課件
- 城中村消防安全培訓(xùn)課件
- 2024-2025學(xué)年北京房山區(qū)初一(上)期末語(yǔ)文試卷
- 《煤礦測(cè)量學(xué)》課件
- 運(yùn)動(dòng)安全課課件下載視頻
- 2025蛇年藍(lán)色寬屏企業(yè)年會(huì)活動(dòng)模板
- 2021年企業(yè)人力資源管理師(四級(jí))考試題庫(kù)及答案解析(單選題)
- 《活動(dòng)提案模板》課件
- 2023-2024學(xué)年仁愛(ài)版七上期末考試英語(yǔ)(試題)
- 無(wú)人機(jī)表演服務(wù)合同
- 呼吸內(nèi)科臨床診療指南及操作規(guī)范
- 學(xué)生管理教育課件
- 物業(yè)經(jīng)理轉(zhuǎn)正述職
- 貿(mào)易崗位招聘面試題及回答建議(某大型國(guó)企)2025年
- 世界職業(yè)院校技能大賽高職組“關(guān)務(wù)實(shí)務(wù)組”賽項(xiàng)參考試題及答案
- 高中歷史教師資格考試面試試題及解答參考(2024年)
- 北師大版(2024新版)生物七年級(jí)上冊(cè)期末考點(diǎn)復(fù)習(xí)提綱
- 期末 試題 -2024-2025學(xué)年人教PEP版英語(yǔ)六年級(jí)上冊(cè) (含答案)
- 2024年理論中心組學(xué)習(xí)心得體會(huì)模版(2篇)
評(píng)論
0/150
提交評(píng)論