温室环境控制系统的设计与实现外文翻译资料

 2022-12-05 16:27:02

Advanced ASP.NET AJAX Server Controls ,2009, 177(5): 97-102.

ASP.NET Technique

Adam Calderon Joel Rumerman

1. Building ASP.NET Pages

ASP.NET and the .NET Framework

ASP.NET is part of Microsofts overall .NET framework, which contains a vast set of programming classes 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 Library

Imagine that you are Microsoft. Imagine that you have to support multiple programming languages—such as Visual Basic, JScript, and C . A great deal of the functionality of these programming languages overlaps. For example, for each language, you would have to include methods for accessing the file system, working with databases, and manipulating strings.

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.

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 functionality 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 programming need. For example, 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 as working with regular expressions and handling network protocols.

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 understand, however, that you can access any of the .NET framework classes when you are building your ASP.NET pages.

Understanding Namespaces

As 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 the .NET framework are organized into a hierarchy of namespaces.

ASP Classic Note

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 to over 3,400 classes!

A namespace is a logical grouping of classes. For example, all the classes 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 namespace 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 class that represents a file system file (the File class), you would use the following:

System.IO.File

System.IO refers to the namespace, and File refers to the particular class.

NOTE

You can view all the namespaces of the standard classes in the .NET Framework Class Library by viewing the Reference Documentation for the .NET Framework.

Standard ASP.NET Namespaces

The 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 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 specialized collections such as linked lists and string collections.

System.Configuration— Contains classes for working with configuration files (Web.config files).

System.Text— Contains classes for encoding, decoding, and manipulating the contents of strings.Advanced ASP.NET AJAX Server Controls,2009,177(5):97-102

Adam Calderon Joel Rumerman

关键词:ASP.NET,窗口,页面验证,控件编程。

ASP.NET 和ASP.NET结构

.NET类库

此外,这些语言包含相似的编程构造。 每种语言,举例来说,都能够使用循环语句和条件语句。 即使用 Visual Basic 写的条件语句的语法不与 用C 写的不一样,程序的功能也是相同的。

对于多种语言来说维持这一功能需要很大的工作量。 为什么继续再创轮子? 对所有的语言创建这种功能一次,然后把这个功能用在每一种语言中岂不是更容易。

.NET framework,此外包含支持所有的基本变量数据类型的类,比如:字符串、整型、字节型、字符型和数组。

理解命名空间

ASP Classic Note

命名空间被组织成一个层次结构(一棵逻辑树) 。 树根就是SYSTEM 命名空间。 这个命名空间包含基本的数据类型的所有的类,例如:字符串、数组,还包含提供随机数字和日期的类。

System.IO.文件

提示

标准的 ASP.NET 命名空间

System 命名空间- 包含所有的基本数据类型和其他有用的类,例如:那些关于产生随机数字和日期的类。

System.Collections.Specialized 命名空间- 包含特殊的集合类,例如:连接列表和字符串集合。

System.Text命名空间-包含编码,解码和操作字符串内容的类。

System.Web 命名空间-工作在万维网方面包含的是浏览器请求和服务器响应的类。

System.Web.Security命名空间- 包含执行验证和授权,例如:窗体和密码验证的类。

System.Web.UI命名空间- 包含构建 ASP.NET 页面的用户接口的类。 System.Web.UI.HTMLControls命名空间- 包含 HTML 控件的类。

.NET Framework -可用的语言

提示

除微软之外的公司产生的几十个其他的语言已经能够和.NET framework兼容。 这些其他的语言的一些例子包括 Python、 SmallTalk 、 Eiffel和 COBOL。这就意味着假如你真的想, 你可以使用 COBOL 写 ASP.NET 页面。

你第一次请求 ASP.NET 页面, 页面被编译成一个.NET类, 这个类文件被保存在一个特殊的目录下这个目录的名字叫Temporary ASP.NET Files。对于一个ASP.NET页面一个通信类文件出现在Temporary ASP.NET Files目录下。以后不管任何时候你请求那个同样的ASP.NET页面,那个通信类文件就会执行。

一个ASP.NET 页面不会被编译成本地机器码直到它被一个浏览器访问,在那个时间点包含在Temporary ASP.NET Files目录下的类文件用JIT编译器编译并且执行。

典型ASP提示

ASP.NET 不支持VBScript ,而且这是好消息。 Visual Basic 是一个 VBScript 的超集,意味着 Visual Basic 相对于 VBScript有更多的功能。 因此, 你用 Visual Basic 有更丰富的函数和语句供你使用。

假如你过去只用VBScript而不用 Visual Basic,也不用担心。 因为 VBScript 如此接近 Visual Basic, 你将会发现在这二种语言之间的转变是很容易的。

在.NET framework中,微软包括一个名叫 IL Disassembler的有趣的工具。在临时的ASP.NET文件目录中你能使用这个工具查看没有装配的ASP.NET 类的代码。 它列出了类的所有方法和属性使你能够浏览中间代码。

介绍 ASP.NET 控件

ASP.NET 控件和 HTML 内容共存。 典型地,你用通常的 HTML 创建你的网页的静态区域和用 ASP.NET 控件创建网页的动态区域。

添加ASP.NET页面的代码

如果一个使用者单击 HTML窗体中的Button按钮, 举例来说,那个按钮就会响应一个事件 (单击事件) 。 典型地,你想添加代码响应这个事件到页面中。 举例来说,当某人单击Button按钮控件的时候,你可以保存窗体数据到一个文件或者数据库。

2. 用Web服务器控件创建窗体

你用几个基本Web控件来代替标准的 HTML 窗体元素,例如radio buttons、text boxes, and list boxes. 你能够用这些控件为你的Web应用程序在你的ASP.NET页面中创建用户界面。 下面的部分为这些Web控件提供了详细的提纲和程序源代码。

在下列的部分中,你学会如何控制一个用户从一个ASP.NET页面转到另一个页面。首先,你学会怎么把一个HTML窗体链接到另一个页面来获取信息。 下一步,你学会用Redirect()方法自动让一个用户浏览一个新的页面。 最后,你学会用超级链接控件怎么把页面连在一起。

在下列的部分中,你学会该如何创建更有吸引力的Web窗体。 首先,你浏览一下针对所有Web控件格式属性他们是基本控件类的格式属性。 然后,你学会在Web控件上应用样式表风格。

使用客户端验证

写验证代码到客户端代码中的优势能够及时反馈到你的用户。 举例来说,一个使用者忽略在一个要求检验的字段中输入一个值,你能够及时的显示一个错误信息而不需要返回到服务器端解决。

由于这个原因,许多开发者在过去决定添加自定义验证到服务器端。因为服务器端代码能够和任何浏览器协同工作。就这样的做法更有安全的保障。

然而你需要注意的是,客户端的验证仅仅能够工作在IE4.0或更高的版本。 尤其,正如这一章讨论的客户端脚本不可能在任意本本的浏览器中运行。

剩余内容已隐藏,支付完成后下载完整资料


lt;a id='idd

资料编号:[25277],资料为PDF文档或Word文档,PDF文档可免费转换为Word

您需要先支付 30元 才能查看全部内容!立即支付

发小红书推广免费获取该资料资格。点击链接进入获取推广文案即可: Ai一键组稿 | 降AI率 | 降重复率 | 论文一键排版