计算机外文文献+翻译(.net).docx
《计算机外文文献+翻译(.net).docx》由会员分享,可在线阅读,更多相关《计算机外文文献+翻译(.net).docx(26页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、东北石油大学本科毕业设计英文文献及翻译学院计算机与信息技术学院班级 计科07-1班学号姓名指导教师职称副教授键入文字1对控件应用格式在下列的部分中,你学会该如何创建更有吸引力的Web窗体。首先, 你浏览一下针对所有Web控件格式属性他们是基本控件类的格式属性。 然后,你学会在Web控件上应用样式表风格。3用验证控件做页面验证使用客户端验证传统地,当增加验证到他们的页面中时,他们会面临一个严峻的选 择。你可以添加窗体页面验证规则到你的服务器端代码,或者是添加验 证规则到你的客户端代码。写验证代码到客户端代码中的优势能够及时反馈到你的用户。举例 来说,一个使用者忽略在一个要求检验的字段中输入一个值
2、,你能够及 时的显示一个错误信息而不需要返回到服务器端解决。人们喜欢客户端的验证。它看起来很棒而且产生一种比较好的效 果。然而,问题是它不与所有的浏览器兼容。不是所有的浏览器支持 JavaScript不同版本的浏览器的不同版本支持JavaScript所以客户端验证没 有保障。由于这个原因,许多开发者在过去决定添加自定义验证到服务器端。 因为服务器端代码能够和任何浏览器协同工作。就这样的做法更有安全 的保障。键入文字1幸运地,正如在章节讨论的这些验证控件不会强迫你做困难的选择。 这些验证控件会自动地产生客户端代码和服务器端代码。如果一个浏览 器有能力支持JavaScript,客户端的验证脚本将会
3、自动返回到浏览器。如果 一个浏览器不支持JavaScrip邨个验证规则会自动在服务器端代码中执行。然而你需要注意的是,客户端的驹证仅仅能够工作在正4。或更高的 版本。尤其,正如这一章讨论的客户端脚本不可能在任意本本的浏览器 中运行。控制字段:RequiredFieldValidato盥牛你用这个控件来检查在一个Web窗体中是否为空,典型地,你和 TextBox控件一起使用这个控件。然而,这个控件也可以用在其他的输 入型控件,例如:RadioButtonLisffio验证表达式:RegularExpressionValidato蟀件你能使用RegularExpressionValidat控件来验
4、证输入的值是否和定义 的正则表达式相匹配。例如:你能使用这控件来检查一个用户是否输入 一个合法的电子邮件地址,电话号码,用户名或密码。怎样用一个正则 表达式来完成这些验证任务将会在下面的例子中一一列出。10键入文字1比较值:CompareValidator 控件这个CompareValidator控件用于比较一个输入的数据和另外一个值 是否相同。另外一个值可能是固定值,例如:一个特定的数字或者是输 入到另一个控件中的一个值。总结错误:ValidationSummary控件假想一个页面有50个字段假如你仅仅用上部分讨论的那些验证控件 来显示错误看见一个错误在页面中将是很难的。例如:你可能需要滚动
5、 到第48个页面字段来找到这个错误信息。幸好,微软除了包含上面提到的控件还包括Validationsummary控 件。你能用这控件综合所有的错误信息在一个页面的上端或者你想要的 任何一个地方。4先进的控件编程保存浏览状态默认地,几乎所有的ASP.NET控件都会在先前的窗体中保留他们 的属性值。举例来说,如果你输入文本到一个Lebel标签上然后提交那个 页面,当那个页面再次被访问那个Lebel标签的内容将会被保存下来。浏览状态的妙处是它不依赖任何的特定服务器或浏览器的属性。尤 其,它不依赖cookies,sessio变量、或应用程序变量。浏览状态在一个 名叫做VIEWSTATE 的隐藏页面中执
6、行,这个隐藏页面自动创建每个Web11键入文字1窗体。当灵活的应用时,浏览状态能够在你的网站中产生艺术性的和积极的 效果,例如:如果你在一个支持浏览状态的控件中显示数据库数据,你 不需要每次都返回到需要反馈到服务器的数据库页面。你能够自动地保 存页面里的数据状态。显示和隐藏内容假想你正在用一个可选择的部分创造页面。举例来说,假想你正在 创造一种在线纳税系统,而且你想要显示或者隐藏一个包含适用于已婚 的税文件编档员的问题的部分。或者,假想你想要添加一个帮助按钮到网站上去。你可能想要隐藏 或者显示完成依靠用户参考的问题的详细说明。最后,假想你想要把一个tax form变成很多页面,以便一个人每次
7、只看那个tax for 一部分。在下列的部分中,你学会用属性设置在一个窗体中来隐藏或显示控 件。你学会用单个控件和一组控件设置Visible and Enab属性来隐藏和显 示页面内容。使用 Visible andEnabled属性每个控件包括HTML和Web控件有一个Visible属性来决定那个 控件是否可见。当一个控件的Visibl是fals值,那个控件就不会在页面 上显示;那个控件也不会进一步运行。Web控件(不是每个HTML控件)还有一个叫Enabled的属性。当12【键入文字1Enabled的属性是false值,你用的浏览器是IE4.0或更高的版本那个控件被 封住了,也不起作用了,当
8、用其他的浏览器的时候,如:网景浏览器那 个控件不会被封,但它也是不起作用的。使浏览状态失效在特定的环境中,你可能想要对一个单独的控件或ASP.NET页面作 为一个整体的浏览状态失效。举例来说,你可能使用一个有包含许多数据 的控件(假想一个RadioButtonLis控件控制1,000个选项)假如你担心页面数 据会大大的降低页面的显示速度,你可能不想要加载数据到隐藏的 VIEWSTATE页面字段。使用丰富页面的控件在下列的部分中,你学会在ASP.NET Framework怎样使用三种特征 控件。学会该如何使用日历控件显示交互式日历,AdRotator控件显示滚 动的广告,HTMLInputFil
9、e控件来接受文件的上传。13键入文字1ASP.NET TechniqueBuilding ASP.NET PagesASP.NET and the .NET FrameworkASP.NET is part of Microsofts overall .NET framework, which containsa vast set of programming classesdesigned to satisfyany conceivable programming need.In the following two sections, you learn how ASP.NETfits wi
10、thin the .NET framework, and you learn about the languages you canuse in your ASP.NET pages.The .NET Framework Class LibraryImagine thatyou are Microsoft.Imagine thatyou have to support multipleprogramming languagesuch as Visual Basic, JScript, and C+. A great deal of the functionality of these prog
11、ramming languages overlaps.example, for each language, you would have to include methods for accessi the file system, working with databases, and manipulating strings.Furthermore,theselanguagescontainsimilarprogramming constructs.Every language,forexample,can representloopsand conditionalsE.ven thou
12、gh the sy ntaxofa conditionaitterin VisualB asic differfromthe syntax of a conditional written in C+, the programming function is theFinallynostprogramminglanguages have similar varriitetypes.In most languages, you have some means of representing strings and intege14键入文字1for example. The maximum and
13、 minimum size of an integer might depend on the language but the basic data type is the same.Maintaining all this functionality for multiple languages requires a work. Why keep reinventing the wheel? Wouldnt it be easier to create all functionality once and use it for every language?The .NET Framewo
14、rk ClassLibrarydoesexactl)thatItconsistfa vast set of classes designed to satisfy any conceivable programming need, example, the .NET framework contains classes for handling database access working with the file system, manipulating text, and generating graphics, additionjtcontainsnore specializedas
15、seforperformingtaskssuchas working with regular expressions and handling network protocols.The .NET framework, furthermore, contains classes that represent all basic variabldatatypessuch as stringsjntegersfytescharactersgidarrays.Most importantly, for purposes of this book, the .NET Framework ClassL
16、ibrarycontainsclassesfor buildingASP.NETpages.You need tounderstand, however, that you can access any of the .NET framework classe when you are building your ASP.NET pages.Understanding NamespacesAs you might guess, the .NET framework is huge. It contains thousandsof classes(over3,400).Fortunatelyt,
17、heclassesarenotsimplyjumbled15键入文字1together. The classes of the .NET framework are organized into a hierarch namespaces.ASP Classic NoteIn previous versions of Active Server Pages, you had access to only standarcfclassetheResponse,Request,SessionApplication9id Server objects)ASP.NET,in contrastgovid
18、esyou with access to over3,400 classes!A namespace isa logicaroupingofclassesFor example,allthe classes that relate to working with the file system are gathered together the System.IO namespace.The namespacesareorganizedntoahierarchalogicatree)A the rootofthe treeistheSystemnamespace.Thisnamespaceco
19、ntainsallthe classeforthebase datatypes3uchasstringandarraysltalsocontains classes for working with random numbers and dates and times.You can uniquely identify any class in the .NET framework by using th full namespace of the class. For exfiropliajquely refer to the class that represents a file sys
20、tem file (the File class), you would use the followiSystemJO.FileSystem.IO refers to the namespace, and File refers to the particular NOTE16键入文字1You can view allthenamespacesof the standarlassesnthe .NET Framework ClassLibraryby viewing the ReferenceDocumentationfor the .NET Framework.Standard ASP.N
21、ET NamespacesThe classes contained in a select number of namespaces are available yourASP.NET pages by default(You must explicitljmport other namespaces.)Thesedefaultnamespacescontainclassesthatyou usemost often in your ASP.NET applications:System- Contains all the base data types and other useful c
22、lasses su asthoserelateibgeneratingandom numbers and working withdatesand times.System.Collections Contains classesfor working with standard collection types such as hash tables, and array lists.(Contains classes that represent specialized collections such as linked lists and string collections.Syst
23、em.ConfiguratienContains classes for working with configurationfiles (Web.config files).System. Tex JContains classes for encoding, decoding, andmanipulating the contents of strings.17键入文字1System.Text.RegularExpressiensContainsclassesfor performing regular expression match and replace operations.Sys
24、tem.Web一 ContainsthebasicclasseforworkingwiththeWorld Wide Web, includingclassesforrepresentinbgrowserrequestsand server responses.- Contains classes used for caching the content of pages and classes for performing custom caching operations.Contains classes for implementingauthentication and authori
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 外文 文献 翻译 net
限制150内