最基础的东西,高手请过。

vb.net source

C# source


这是界面:

Name: Category:


  页面上的任意 HTML 元素都可以转换为 HTML 服务器控件。通过设置属性就可以实现转换。仅通过添加 RUNAT="SERVER" 属性,就可以把HTML 元素转换为控件。做为代码成员的一部分,还应当为控件分配ID属性。如 上面C#代码的第14行<h3> Name: <asp:textbox id="Name" runat="server"/>。
  用于服务器端处理的HTML页面框架为页面中最常动态使用的 HTML 元素,为我们提供了预定义的 HTML 服务器控件,如:窗体、HTML <INPUT> 元素(文本框、复选框、“提交”按钮等)、列表框 (<SELECT>)、表、图像等等。这些预定义的 HTML 服务器控件具有一般控件的基本属性,此外每个控件通常有自己的属性集和自己的事件。

以下是一段ASP.NET Server Controls的英语说明,有利于帮助理解,起码可以作为技术文档研究。(本人英文有限,读起来有些吃力。)
In addition to code and markup, ASP.NET pages can contain server controls, which are programmable server-side objects that typically represent a UI element in the page, such as a textbox or image. Server controls participate in the execution of the page and produce their own markup rendering to the client. The principle advantage of server controls is that they enable developers to get complex rendering and behaviors from simple building-block components, dramatically reducing the amount of code it takes to produce a dynamic Web page. Another advantage of server controls is that it is easy to customize their rendering or behavior. Server controls expose properties that can be set either declaratively (on the tag) or programmatically (in code). Server controls (and the page itself) also expose events that developers can handle to perform specific actions during the page execution or in response to a client-side action that posts the page back to the server (a "postback"). Server controls also simplify the problem of retaining state across round-trips to the server, automatically retaining their values across successive postbacks.

Server controls are declared within an .aspx file using custom tags or intrinsic HTML tags that contain a runat="server" attribute value. Intrinsic HTML tags are handled by one of the controls in the System.Web.UI.HtmlControls namespace. Any tag that doesn't explicitly map to one of the controls is assigned the type of System.Web.UI.HtmlControls.HtmlGenericControl.

The following sample uses four server controls: <form runat=server>, <asp:textbox runat=server>, <asp:dropdownlist runat=server>, and <asp:button runat=server>. At run time these server controls automatically generate HTML content.
Important: Note that these server controls automatically maintain any client-entered values between round trips to the server. This control state is not stored on the server (it is instead stored within an <input type="hidden"> form field that is round-tripped between requests). Note also that no client-side script is required.

In addition to supporting standard HTML input controls, ASP.NET enables developers to utilize richer custom controls on their pages. For example, the following sample demonstrates how the <asp:adrotator> control can be used to dynamically display rotating ads on a page.


ASP.NET 服务器控件简介

创建 Web 窗体页时,可以使用以下控件类型:

  • HTML 服务器控件   对服务器公开的 HTML 元素,可对其进行编程。HTML 服务器控件公开一个对象模型,该模型十分紧密地映射到相应控件所呈现的 HTML 元素。

  • Web 服务器控件   这些控件比 HTML 服务器控件具有更多内置功能。Web 服务器控件不只包括窗体类型的控件,例如按钮和文本框;而且还包括特殊用途的控件,例如日历。Web 服务器控件与 HTML 服务器控件相比更为抽象,因为其对象模型不一定反映 HTML 语法。

  • 验证控件   包含逻辑以允许测试用户输入的控件。将一个验证控件附加到输入控件,测试用户对该输入控件输入的内容。验证控件可用于检查必填字段,对照字符的特定值或模式进行测试,验证某个值是否在限定范围之内以及其他目的。

  • 用户控件   作为 Web 窗体页创建的控件。Web 窗体用户控件可以嵌入到其他 Web 窗体页中,这是创建菜单、工具栏和其他可重用元素的捷径。

 

posted on 2006-04-16 01:10  fireflies  阅读(637)  评论(0编辑  收藏  举报