畢業(yè)論文基于WEB的學(xué)生作業(yè)管理系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)_第1頁(yè)
畢業(yè)論文基于WEB的學(xué)生作業(yè)管理系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)_第2頁(yè)
畢業(yè)論文基于WEB的學(xué)生作業(yè)管理系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)_第3頁(yè)
畢業(yè)論文基于WEB的學(xué)生作業(yè)管理系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)_第4頁(yè)
畢業(yè)論文基于WEB的學(xué)生作業(yè)管理系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)_第5頁(yè)
已閱讀5頁(yè),還剩27頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、I / 32 文檔可自由編輯打印摘摘 要要1.1.構(gòu)建構(gòu)建 ASP.NETASP.NET 頁(yè)面頁(yè)面 ASP.NET 和 ASP.NET 結(jié)構(gòu)ASP.NET 是微軟.NET framework 整體的一部分, 它包含一組大量的編程用的類,滿足各種編程需要。 在下列的二個(gè)部分中, 你如何學(xué)會(huì) ASP.NET 很適合的放在.NET framework, 和學(xué)會(huì)能在你的 ASP.NET 頁(yè)面中使用語(yǔ)言。 .NET 類庫(kù)假想你是微軟。 假想你必須支持大量的編程語(yǔ)言-比如 Visual Basic 、 JScript 和 C+. 這些編程語(yǔ)言的很多功能具有重疊性。 舉例來(lái)說(shuō),對(duì)于每一種語(yǔ)言,你必須包括存取

2、文件系統(tǒng)、與數(shù)據(jù)庫(kù)協(xié)同工作和操作字符串的方法。此外,這些語(yǔ)言包含相似的編程構(gòu)造。 每種語(yǔ)言,舉例來(lái)說(shuō),都能夠使用循環(huán)語(yǔ)句和條件語(yǔ)句。即使用 Visual Basic 寫的條件語(yǔ)句的語(yǔ)法不與 用 C+ 寫的不一樣,程序的功能也是相同的。 最后,大多數(shù)的編程語(yǔ)言有相似的數(shù)據(jù)變量類型。 以大多數(shù)的語(yǔ)言,你有設(shè)定字符串類型和整型數(shù)據(jù)類型的方法。舉例來(lái)說(shuō),整型數(shù)據(jù)最大值和最小值可能依賴語(yǔ)言的種類,但是基本的數(shù)據(jù)類型是相同的。對(duì)于多種語(yǔ)言來(lái)說(shuō)維持這一功能需要很大的工作量。 為什么繼續(xù)再創(chuàng)輪子? 對(duì)所有的語(yǔ)言創(chuàng)建這種功能一次,然后把這個(gè)功能用在每一種語(yǔ)言中豈不是更容易。 .NET 類庫(kù)不完全是那樣。 它含有

3、大量的滿足編程需要的類。舉例來(lái)說(shuō),.NET 類庫(kù)包含處理數(shù)據(jù)庫(kù)訪問(wèn)的類和文件協(xié)同工作,操作文本和生成圖像。除此之外,它包含更多特殊的類用在正則表達(dá)式和處理 Web 協(xié)議。 .NET framework,此外包含支持所有的基本變量數(shù)據(jù)類型的類,比如:字符串、整型、字節(jié)型、字符型和數(shù)組最重要地, 寫這一本書的目的, .NET 類庫(kù)包含構(gòu)建的 ASP.NET 頁(yè)面的類。然而你需要了解當(dāng)你構(gòu)建.NET 頁(yè)面的時(shí)候能夠訪問(wèn).NET framework 的任意類。理解命名空間 正如你猜測(cè)的, .NET framework 是龐大的。 它包含數(shù)以千計(jì)的類。 (超過(guò) 3,400) 幸運(yùn)地,類不是簡(jiǎn)單的堆在一起

4、。.NET framework 的類被組織成有層次結(jié)構(gòu)的命名空間。ASP Classic Note在先前的 ASP 中,你僅僅能夠訪問(wèn)五個(gè)標(biāo)準(zhǔn)類II / 32 文檔可自由編輯打印。相比之下 ASP.NET 提供超過(guò) 3,400 個(gè)類!一個(gè)命名空間包含一組邏輯的類。 舉例來(lái)說(shuō),涉及到與文件系統(tǒng)協(xié)同工作的類就集合在 System.IO 命名空間中。 命名空間被組織成一個(gè)層次結(jié)構(gòu)(一棵邏輯樹) 。 樹根就是 SYSTEM 命名空間。 這個(gè)命名空間包含基本的數(shù)據(jù)類型的所有的類,例如:字符串、數(shù)組,還包含提供隨機(jī)數(shù)字和日期的類。你通過(guò)完整的類的命名空間能唯一識(shí)別任何的類在.NET framework 中

5、的位置。 舉例來(lái)說(shuō),指定找到一個(gè) the 類,按如下操 System.IO.文件System.IO 指命名空間 ,而文件指定特定的類。 你能夠?yàn)g覽.NET Framework 所有的標(biāo)準(zhǔn)類的命名空間。通過(guò).NET Framework 的參考文檔可以瀏覽類庫(kù)。標(biāo)準(zhǔn)的 ASP.NET 命名空間在默認(rèn)情況下,在你的 ASP.NET 頁(yè)面中,類被包含在一個(gè)選定的命名空間中這些默認(rèn)的命名空間使你在 ASP.NET 中最常用到的。System 命名空間- 包含所有的基本數(shù)據(jù)類型和其他有用的類,例如:那些關(guān)于產(chǎn)生隨機(jī)數(shù)字和日期的類。System.Collections 命名空間- 包含的類是標(biāo)準(zhǔn)的集合類,例

6、如:哈希表,數(shù)組列表。System.Collections.Specialized 命名空間- 包含特殊的集合類,例如:連接列表和字符串集合。 System.Configuration 命名空間- 包括 Web.config files 類。System.Text 命名空間-包含編碼,解碼和操作字符串內(nèi)容的類。System.Text.RegularExpressions 命名空間- 包含的是匹配正則表達(dá)式和替代操作類。System.Web 命名空間-工作在萬(wàn)維網(wǎng)方面包含的是瀏覽器請(qǐng)求和服務(wù)器響應(yīng)的類。System.Web.Caching 命名空間- 包含頁(yè)面緩沖內(nèi)容和自定義緩沖操作的類。Sys

7、tem.Web.Security 命名空間- 包含執(zhí)行驗(yàn)證和授權(quán),例如:窗體和密碼驗(yàn)證的類。System.Web.SessionState 命名空間- 包含執(zhí)行保存狀態(tài)的類。System.Web.UI 命名空間- 包含構(gòu)建 ASP.NET 頁(yè)面的用戶接口的類。System.Web.UI.HTMLControls 命名空間- 包含 HTML 控件的類。III / 32 文檔可自由編輯打印System.Web.UI.WebControls 命名空間- 包含 Web 控件的類。.NET Framework -可用的語(yǔ)言這一本書的目的, 你將會(huì)為以 Visual Basic 作為你的編程語(yǔ)言來(lái)完成你的

8、 ASP.NET 頁(yè)寫程序編寫。 它是 ASP.NET 頁(yè)面的默認(rèn)語(yǔ)言。雖然你在這一本書中一直用 Visual Basic, 但是,你也需要了解用其它的支持公共語(yǔ)言庫(kù)的語(yǔ)言創(chuàng)建 ASP.NET 頁(yè)面。除此之外,這包括 C#, JScript.NET 和 C+ 。 除微軟之外的公司產(chǎn)生的幾十個(gè)其他的語(yǔ)言已經(jīng)能夠和.NET framework 兼容。 這些其他的語(yǔ)言的一些例子包括 Python、 SmallTalk 、 Eiffel 和 COBOL。這就意味著假如你真的想, 你可以使用 COBOL 寫 ASP.NET 頁(yè)面。不管你使用什么語(yǔ)言開發(fā) ASP.NET 頁(yè)面,你需要明白 ASP.NET

9、在執(zhí)行前必須編譯,這就意味著 ASP.NET 執(zhí)行速度非常快。 你第一次請(qǐng)求 ASP.NET 頁(yè)面, 頁(yè)面被編譯成一個(gè).NET 類, 這個(gè)類文件被保存在一個(gè)特殊的目錄下這個(gè)目錄的名字叫 Temporary ASP.NET Files。對(duì)于一個(gè) ASP.NET 頁(yè)面一個(gè)通信類文件出現(xiàn)在 Temporary ASP.NET Files 目錄下。以后不管任何時(shí)候你請(qǐng)求那個(gè)同樣的 ASP.NET 頁(yè)面,那個(gè)通信類文件就會(huì)執(zhí)行。 當(dāng) ASP.NET 頁(yè)面被編譯的時(shí)候,它沒被直接地被編譯成機(jī)器碼而是被編譯成了一個(gè)中間語(yǔ)言,名字叫 (MSIL)所有.NET 可用的語(yǔ)言都被編譯成這種中間語(yǔ)言。 一個(gè) ASP.

10、NET 頁(yè)面不會(huì)被編譯成本地機(jī)器碼直到它被一個(gè)瀏覽器訪問(wèn),在那個(gè)時(shí)間點(diǎn)包含在 Temporary ASP.NET Files 目錄下的類文件用 JIT 編譯器編譯并且執(zhí)行。這些迷惑的方面體現(xiàn)在整個(gè)過(guò)程都在后臺(tái)運(yùn)行,你必須要做的是用資源代碼為你的 ASP.NET 頁(yè)面創(chuàng)建一個(gè)文本文件。.NET framework 為你處理完轉(zhuǎn)換它為編譯碼這一困難工作。VBScript 怎么樣呢? 在 ASP.NET 之前, VBScript 是開發(fā)動(dòng)態(tài)頁(yè)面最流行的語(yǔ)言。ASP.NET 不支持 VBScript ,而且這是好消息。 Visual Basic 是一個(gè) VBScript 的超集,意味著 Visual

11、Basic 相對(duì)于 VBScript 有更多的功能。 因此, 你用 Visual Basic 有更豐富的函數(shù)和語(yǔ)句供你使用。此外,不像 VBScript , Visual Basic 是一種被編譯的語(yǔ)言。這意味著如果你使用 Visual Basic 重寫相同的 VBScript 代碼感覺會(huì)更容易一些。IV / 32 文檔可自由編輯打印假如你過(guò)去只用 VBScript 而不用 Visual Basic,也不用擔(dān)心。因?yàn)?VBScript 如此接近 Visual Basic, 你將會(huì)發(fā)現(xiàn)在這二種語(yǔ)言之間的轉(zhuǎn)變是很容易的。在.NET framework 中,微軟包括一個(gè)名叫 IL Disassemb

12、ler 的有趣的工具。在臨時(shí)的 ASP.NET 文件目錄中你能使用這個(gè)工具查看沒有裝配的 ASP.NET 類的代碼。它列出了類的所有方法和屬性使你能夠?yàn)g覽中間代碼。正如在這章討論的這個(gè)工具也可以用于操作 ASP.NET 控件。 舉例來(lái)說(shuō),你能使用 IL Disassembler 瀏覽 TextBox 控件的中間代碼。(位于在一個(gè)叫做 System.Web.dll 的文件中)介紹 ASP.NET 控件ASP.NET 控件為你的 Web 應(yīng)用程序提供動(dòng)態(tài)和交互的用戶接口。這些控件能夠使你的網(wǎng)站的使用者看見和交互。舉例來(lái)說(shuō),你能使用控件建立 HTML 窗體元素,交互式日歷, 而且可以滾動(dòng)標(biāo)題廣告。

13、ASP.NET 控件和 HTML 內(nèi)容共存。 典型地,你用通常的 HTML 創(chuàng)建你的網(wǎng)頁(yè)的靜態(tài)區(qū)域和用 ASP.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è)面的代碼,他是確切的頁(yè)面的程序代碼,在你添加的程序用戶處理控件也頁(yè)面事件。如果一個(gè)使用者單擊 HTML 窗體中的 Button 按鈕, 舉例來(lái)說(shuō),那個(gè)按鈕就會(huì)響應(yīng)一個(gè)事件 (單擊事件) 。 典型地,你想添加代碼響應(yīng)這個(gè)事件到頁(yè)面中。 舉例來(lái)說(shuō),當(dāng)某人單擊 Button 按鈕控件的時(shí)候,你可以保存窗體

14、數(shù)據(jù)到一個(gè)文件或者數(shù)據(jù)庫(kù)。 控件不是唯一的能相應(yīng)事件的事物。 當(dāng)它被請(qǐng)求的時(shí)候一個(gè) ASP.NET 頁(yè)面每次都能夠響應(yīng)幾個(gè)事件。 舉例來(lái)說(shuō),每當(dāng)你請(qǐng)求一個(gè)頁(yè)面,頁(yè)面的初始化事件就會(huì)被觸發(fā)。 每當(dāng)初始化事件發(fā)生的時(shí)候,你能夠添加代碼到頁(yè)面中來(lái)執(zhí)行。 2.2. 用用 WebWeb 服務(wù)器控件創(chuàng)建窗體服務(wù)器控件創(chuàng)建窗體 構(gòu)建靈活窗體你用幾個(gè)基本 Web 控件來(lái)代替標(biāo)準(zhǔn)的 HTML 窗體元素,例如 radio buttons、text boxes, and list boxes. 你能夠用這些控件為你的 Web 應(yīng)用程序在你的 ASP.NET 頁(yè)面中創(chuàng)建用戶界面。下面的部分為這些 Web 控件提供了詳

15、細(xì)的提綱和程序源代碼。V / 32 文檔可自由編輯打印控制頁(yè)面瀏覽 在下列的部分中,你學(xué)會(huì)如何控制一個(gè)用戶從一個(gè) ASP.NET 頁(yè)面轉(zhuǎn)到另一個(gè)頁(yè)面。首先,你學(xué)會(huì)怎么把一個(gè) HTML 窗體鏈接到另一個(gè)頁(yè)面來(lái)獲取信息。下一步,你學(xué)會(huì)用 Redirect()方法自動(dòng)讓一個(gè)用戶瀏覽一個(gè)新的頁(yè)面。 最后,你學(xué)會(huì)用超級(jí)鏈接控件怎么把頁(yè)面連在一起。 對(duì)控件應(yīng)用格式在下列的部分中,你學(xué)會(huì)該如何創(chuàng)建更有吸引力的 Web 窗體。 首先,你瀏覽一下針對(duì)所有 Web 控件格式屬性他們是基本控件類的格式屬性。然后,你學(xué)會(huì)在 Web 控件上應(yīng)用樣式表風(fēng)格。3.3. 用驗(yàn)證控件做頁(yè)面驗(yàn)證用驗(yàn)證控件做頁(yè)面驗(yàn)證使用客戶端驗(yàn)證

16、傳統(tǒng)地,當(dāng)增加驗(yàn)證到他們的頁(yè)面中時(shí),他們會(huì)面臨一個(gè)嚴(yán)峻的選擇。 你可以添加窗體頁(yè)面驗(yàn)證規(guī)則到你的服務(wù)器端代碼,或者是添加驗(yàn)證規(guī)則到你的客戶端代碼。 寫驗(yàn)證代碼到客戶端代碼中的優(yōu)勢(shì)能夠及時(shí)反饋到你的用戶。 舉例來(lái)說(shuō),一個(gè)使用者忽略在一個(gè)要求檢驗(yàn)的字段中輸入一個(gè)值,你能夠及時(shí)的顯示一個(gè)錯(cuò)誤信息而不需要返回到服務(wù)器端解決。人們喜歡客戶端的驗(yàn)證。 它看起來(lái)很棒而且產(chǎn)生一種比較好的效果。 然而,問(wèn)題是它不與所有的瀏覽器兼容。不是所有的瀏覽器支持 JavaScript、不同版本的瀏覽器的不同版本支持 JavaScript,所以客戶端驗(yàn)證沒有保障。由于這個(gè)原因,許多開發(fā)者在過(guò)去決定添加自定義驗(yàn)證到服務(wù)器端。

17、因?yàn)榉?wù)器端代碼能夠和任何瀏覽器協(xié)同工作。就這樣的做法更有安全的保障。 幸運(yùn)地,正如在章節(jié)討論的這些驗(yàn)證控件不會(huì)強(qiáng)迫你做困難的選擇。 這些驗(yàn)證控件會(huì)自動(dòng)地產(chǎn)生客戶端代碼和服務(wù)器端代碼。如果一個(gè)瀏覽器有能力支持 JavaScript ,客戶端的驗(yàn)證腳本將會(huì)自動(dòng)返回到瀏覽器。 如果一個(gè)瀏覽器不支持 JavaScript,那個(gè)驗(yàn)證規(guī)則會(huì)自動(dòng)在服務(wù)器端代碼中執(zhí)行。然而你需要注意的是,客戶端的驗(yàn)證僅僅能夠工作在 IE4.0 或更高的版本。尤其,正如這一章討論的客戶端腳本不可能在任意本本的瀏覽器中運(yùn)行??刂谱侄? RequiredFieldValidator 控件你用這個(gè)控件來(lái)檢查在一個(gè) Web 窗體中是

18、否為空, 典型地,你和 TextBox 控件一起使用這個(gè)控件。 然而,這個(gè)控件也可以用在其他的輸入型控件,例如:RadioButtonList.控件。驗(yàn)證表達(dá)式: RegularExpressionValidator 控件VI / 32 文檔可自由編輯打印你能使用 RegularExpressionValidator 控件來(lái)驗(yàn)證輸入的值是否和定義的正則表達(dá)式相匹配。例如:你能使用這控件來(lái)檢查一個(gè)用戶是否輸入一個(gè)合法的電子郵件地址,電話號(hào)碼,用戶名或密碼。怎樣用一個(gè)正則表達(dá)式來(lái)完成這些驗(yàn)證任務(wù)將會(huì)在下面的例子中一一列出。 比較值: CompareValidator 控件這個(gè) CompareVal

19、idator 控件用于比較一個(gè)輸入的數(shù)據(jù)和另外一個(gè)值是否相同。另外一個(gè)值可能是固定值,例如:一個(gè)特定的數(shù)字或者是輸入到另一個(gè)控件中的一個(gè)值??偨Y(jié)錯(cuò)誤: ValidationSummary 控件假想一個(gè)頁(yè)面有 50 個(gè)字段假如你僅僅用上部分討論的那些驗(yàn)證控件來(lái)顯示錯(cuò)誤看見一個(gè)錯(cuò)誤在頁(yè)面中將是很難的。例如:你可能需要滾動(dòng)到第 48 個(gè)頁(yè)面字段來(lái)找到這個(gè)錯(cuò)誤信息。幸好,微軟除了包含上面提到的控件還包括 ValidationSummary 控件。 你能用這控件綜合所有的錯(cuò)誤信息在一個(gè)頁(yè)面的上端或者你想要的任何一個(gè)地方。4.4. 先進(jìn)的控件編程先進(jìn)的控件編程保存瀏覽狀態(tài)默認(rèn)地,幾乎所有的 ASP.NET

20、 控件都會(huì)在先前的窗體中保留他們的屬性值。舉例來(lái)說(shuō),如果你輸入文本到一個(gè) Lebel 標(biāo)簽上然后提交那個(gè)頁(yè)面,當(dāng)那個(gè)頁(yè)面再次被訪問(wèn)那個(gè) Lebel 標(biāo)簽的內(nèi)容將會(huì)被保存下來(lái)。瀏覽狀態(tài)的妙處是它不依賴任何的特定服務(wù)器或?yàn)g覽器的屬性。 尤其,它不依賴 cookies, session 變量、或應(yīng)用程序變量。 瀏覽狀態(tài)在一個(gè)名叫做VIEWSTATE 的隱藏頁(yè)面中執(zhí)行,這個(gè)隱藏頁(yè)面自動(dòng)創(chuàng)建每個(gè) Web 窗體。當(dāng)靈活的應(yīng)用時(shí), 瀏覽狀態(tài)能夠在你的網(wǎng)站中產(chǎn)生藝術(shù)性的和積極的效果,例如:如果你在一個(gè)支持瀏覽狀態(tài)的控件中顯示數(shù)據(jù)庫(kù)數(shù)據(jù),你不需要每次都返回到需要反饋到服務(wù)器的數(shù)據(jù)庫(kù)頁(yè)面。你能夠自動(dòng)地保存頁(yè)面里的

21、數(shù)據(jù)狀態(tài)。 顯示和隱藏內(nèi)容假想你正在用一個(gè)可選擇的部分創(chuàng)造頁(yè)面。 舉例來(lái)說(shuō),假想你正在創(chuàng)造一種在線納稅系統(tǒng),而且你想要顯示或者隱藏一個(gè)包含適用于已婚的稅文件編檔員的問(wèn)題的部分?;蛘? 假想你想要添加一個(gè)幫助按鈕到網(wǎng)站上去。 你可能想要隱藏或者顯示完成依靠用戶參考的問(wèn)題的詳細(xì)說(shuō)明。VII / 32 文檔可自由編輯打印最后,假想你想要把一個(gè) tax form 變成很多頁(yè)面,以便一個(gè)人每次只看那個(gè) tax form 的一部分。 在下列的部分中,你學(xué)會(huì)用屬性設(shè)置在一個(gè)窗體中來(lái)隱藏或顯示控件。 你學(xué)會(huì)用單個(gè)控件和一組控件設(shè)置 Visible and Enabled 屬性來(lái)隱藏和顯示頁(yè)面內(nèi)容。使用 Vis

22、ible and Enabled 屬性每個(gè)控件,包括 HTML 和 Web 控件,有一個(gè) Visible 屬性來(lái)決定那個(gè)控件是否可見。當(dāng)一個(gè)控件的 Visible 是 false 值,那個(gè)控件就不會(huì)在頁(yè)面上顯示;那個(gè)控件也不會(huì)進(jìn)一步運(yùn)行。Web 控件 (不是每個(gè) HTML 控件) 還有一個(gè)叫 Enabled 的屬性。當(dāng) Enabled的屬性是 false 值,你用的瀏覽器是 IE4.0 或更高的版本那個(gè)控件被封住了,也不起作用了,當(dāng)用其他的瀏覽器的時(shí)候,如:網(wǎng)景瀏覽器那個(gè)控件不會(huì)被封,但它也是不起作用的。使瀏覽狀態(tài)失效在特定的環(huán)境中,你可能想要對(duì)一個(gè)單獨(dú)的控件或 ASP.NET 頁(yè)面作為一個(gè)整

23、體的瀏覽狀態(tài)失效。舉例來(lái)說(shuō), 你可能使用一個(gè)有包含許多數(shù)據(jù)的控件.(假想一個(gè) RadioButtonList 控件控制 1,000 個(gè)選項(xiàng))假如你擔(dān)心頁(yè)面數(shù)據(jù)會(huì)大大的降低頁(yè)面的顯示速度,你可能不想要加載數(shù)據(jù)到隱藏的 VIEWSTATE 頁(yè)面字段。ASP.NET TechniqueAbstract1.Building ASP.NET PagesASP.NET and the .NET FrameworkASP.NET is part of Microsofts overall .NET framework, which contains a vast set of programming cla

24、sses designed to satisfy any conceivable programming 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 pages.The .NET Framework Class LibraryImagine that you are Microsoft. Imagine that you have to

25、 support multiple programming languagessuch as Visual Basic, JScript, and C+. A great deal of the VIII / 32 文檔可自由編輯打印functionality of these programming languages overlaps. For example, for each language, you would have to include methods for accessing the , working with databases, and manipulating s

26、trings.Furthermore, these languages contain similar programming constructs. Every language, for example, can represent loops and conditionals. Even though the syntax of a conditional written in Visual Basic differs from the syntax of a conditional written in C+, the programming function is the same.

27、Finally, most programming languages have similar variable data 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 on the language, but the basic data type is the same.Maintaining all this functional

28、ity for multiple languages requires a lot of work. Why keep reinventing the wheel? Wouldnt it be easier to create all this functionality once and use it for every language?The .NET Framework Class Library does exactly that. It consists of a vast set of classes designed to satisfy any conceivable pro

29、gramming need. For example, the .NET framework contains classes for handling database access, working with the , manipulating text, and generating graphics. In addition, it contains more specialized classes for performing tasks such as working with regular expressions and handling network protocols.

30、The .NET framework, furthermore, contains classes that represent all the basic variable data types such as strings, integers, bytes, characters, and arrays.Most importantly, for purposes of this book, the .NET Framework Class Library contains classes for building ASP.NET pages. You need to understan

31、d, however, that you can access any of the .NET framework classes when you are building your ASP.NET pages.Understanding NamespacesAs you might guess, the .NET framework is huge. It contains thousands of classes (over 3,400). Fortunately, the classes are not simply jumbled together. The classes of t

32、he .NET framework are organized into a hierarchy of namespaces.ASP Classic NoteIX / 32 文檔可自由編輯打印In previous versions of Active Server Pages, you had access to only five standard classes (the Response, Request, Session, Application, and Server objects). ASP.NET, in contrast, provides you with access

33、to over 3,400 classes!A namespace is a logical grouping of classes. For example, all the classes that relate to working with the 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 na

34、mespace 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 the full namespace of the class. For example, to uniquely refer to the

35、 class that represents a file (the ), you would use the following:System.IO.FileSystem.IO refers to the namespace, and to the particular class.NOTEYou can view all the namespaces of the standard classes in the .NET Framework Class Library by viewing the Reference Documentation for the .NET Framework

36、.Standard ASP.NET NamespacesThe classes contained in a select number of namespaces are available in your ASP.NET pages by default. (You must explicitly import other namespaces.) These default namespaces contain classes that you use most often in your ASP.NET applications:System Contains all the base

37、 data types and other useful classes such as those related to generating random numbers and working with dates and times.System.Collections Contains classes for working with standard collection types such as hash tables, and array lists.System.Collections.Specialized Contains classes that represent

38、specialized collections such as linked lists and string collections.System.Configuration Contains classes for working with configuration files (Web.config files).X / 32 文檔可自由編輯打印System.Text Contains classes for encoding, decoding, and manipulating the contents of strings.System.Text.RegularExpressio

39、ns Contains classes for performing regular 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 of p

40、ages and classes for performing custom 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

41、used in building the user interface of ASP.NET pages.System.Web.UI.HTMLControls Contains the classes for the HTML controls.System.Web.UI.WebControls Contains the classes for the Web controls.NET Framework-Compatible LanguagesFor purposes of this book, you will write the application logic for your AS

42、P.NET pages using Visual Basic as your programming language. It is the default language for ASP.NET pages. Although you stick to Visual Basic in this book, you also need to understand that you can create ASP.NET pages by using any language that supports the .NET Common Language Runtime. Out of the b

43、ox, this includes C#, JScript.NET, and the Managed Extensions to C+.NOTEThe CD included with this book contains C# versions of all the code samples.Dozens of other languages created by companies other than Microsoft have been developed to work with the .NET framework. Some examples of these other la

44、nguages include Python, SmallTalk, Eiffel, and COBOL. This means that you could, if you really wanted to, write ASP.NET pages using COBOL.XI / 32 文檔可自由編輯打印Regardless of the language that you use to develop your ASP.NET pages, you need to understand that ASP.NET pages are compiled before they are exe

45、cuted. This means that ASP.NET pages can execute very quickly.The first time you request an ASP.NET page, the page is compiled into a .NET class, and the resulting class saved beneath a special directory on your server named Temporary ASP.NET Files. For each and every ASP.NET page, a corresponding c

46、lass in the Temporary ASP.NET Files directory. Whenever you request the same ASP.NET page in the future, the corresponding class executed.When an ASP.NET page is compiled, it is not compiled directly into machine code. Instead, it is compiled into an intermediate-level language called Microsoft Inte

47、rmediate Language (MSIL). All .NET-compatible languages are compiled into this intermediate language.An ASP.NET page isnt compiled into native machine code until it is actually requested by a browser. At that point, the class in the Temporary ASP.NET Files directory is compiled with the .NET framewo

48、rk Just in Time (JIT) compiler and executed.The magical aspect of this whole process is that it happens automatically in the background. All you have to do is create a text the source code for your ASP.NET page, and the .NET framework handles all the hard work of converting it into compiled code for

49、 you.ASP CLASSIC NOTEWhat about VBScript? Before ASP.NET, VBScript was the most popular language for developing Active Server Pages.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 an

50、d more. So, you have a richer set of functions and statements with Visual Basic.Furthermore, unlike VBScript, Visual Basic is a compiled language. This means that if you use Visual Basic to rewrite the same code that you wrote with VBScript, you can get better performance.XII / 32 文檔可自由編輯打印If you ha

51、ve worked only with VBScript and not Visual Basic in the past, dont worry. Since VBScript is so closely related to Visual Basic, youll find it easy to make the transition between the two languages.NOTEMicrosoft includes an interesting tool named the IL Disassembler (ILDASM) with the .NET framework.

52、You can use this tool to view the disassembled code for any of the ASP.NET classes in the Temporary ASP.NET Files directory. It 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 c

53、hapter. For example, you can use the IL Disassembler to view the intermediate-level code for the TextBox control (located in a System.Web.dll).Introducing ASP.NET ControlsASP.NET controls provide the dynamic and interactive portions of the user interface for your Web application. The controls render

54、 the content that the users of your Web site actually see and interact with. For example, you can use controls to create 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

55、 Web pages with normal HTML content and create the dynamic or interactive portions with ASP.NET controls.The best way to understand how ASP.NET controls work in an HTML page is to look at a simple Web Forms Page.Adding Application Logic to an ASP.NET PageThe second building block of an ASP.NET page

56、is the application logic, which is the actual programming code in the page. You add application logic to a page to handle both control and page events.If a user clicks a Button control within an HTML form, for example, the Button control raises an event (the Click event). Typically, you want to add

57、code to the page that does something in response to this event. For example, when someone clicks the Button control, you might want to save the form data to a database.XIII / 32 文檔可自由編輯打印Controls are not the only things that can raise events. An ASP.NET page itself raises several events every time i

58、t is requested. For example, whenever you request a page, the pages Load event is triggered. You can add application logic to the page that executes whenever the Load event occurs.2. Building Forms with Web Server ControlsBuilding Smart FormsYou use several of the basic Web controls to represent sta

59、ndard HTML form elements such as radio buttons, text boxes, and list boxes. You can use these controls in your ASP.NET pages to create the user interface for your Web application. The following sections provide detailed overviews and programming samples for each of these Web controls.Controlling Pag

60、e NavigationIn the following sections, you learn how to control how a user moves from one ASP.NET page to another. First, you learn how to submit an HTML form to another page and retrieve form information. Next, you learn how to use the Redirect() method to automatically transfer a user to a new pag

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論