当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP.NET > ASP.NET Web 表单

ASP.NET
ASP.NET 介绍
ASP 和 ASP.NET 之间的区别
asp.net的安装
asp.net的网页
ASP.NET - 服务器控件
ASP.NET - 事件
ASP.NET Web 表单
ASP.NET 维持浏览状态
ASP.NET - TextBox(文本框)控件
ASP.NET - 按钮控件
ASP.NET - Data Binding(数据绑定)
ASP.NET - The ArrayList Object(数组列表对象)
ASP.NET - The Hashtable Object 哈希表对象
ASP.NET - The SortedList Object 可排序列表对象
ASP.NET - XML 文件
ASP.NET - Repeater Control 转发器控件
ASP.NET - The DataList Control 数据列表控件
ASP.NET - Database Connection 数据库连接
ASP.NET 2.0 新特征
ASP.NET 2.0 - Master Pages 控制页[主页]

ASP.NET Web 表单


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 918 ::
收藏到网摘: n/a

All server controls must appear within a <form> tag, and the <form> tag must contain the runat="server" attribute.
所有服务器控件必须出现在<form>标签当中,而且<form>标签必须要包含runat='server'属性


ASP.NET Web Forms
ASP.NET Web 表单

The runat="server" attribute indicates that the form should be processed on the server. It also indicates that the enclosed controls can be accessed by server scripts:
runat="server" 属性象征着这个表单应该在服务器上进行处理。这还象征着附在表单里的控件可以被服务端脚本进行访问:

<form runat="server">
...HTML + server controls
...HTML + 服务器控件
</form>

Note: The form is always submitted to the page itself. If you specify an action attribute, it is ignored. If you omit the method attribute, it will be set to method="post" by default. Also, if you do not specify the name and id attributes, they are automatically assigned by ASP.NET.
注意:表单总是会提交到自身页面上。如果你指定了action属性,它会被忽略。如果你没指定method属性,它会默认的设置为method='post'。如果你没有指定name和id属性,ASP.net会自动的给予分配。

Note: An .aspx page can only contain ONE <form runat="server"> control!
注意:一个aspx页面只可以含有一个<form runat="server">控件!

If you select view source in an .aspx page containing a form with no name, method, action, or id attribute specified, you will see that ASP.NET has added these attributes to the form. It looks something like this:
如果你选择查看一个没有指定name,method , action或id属性表单的.aspx页面,你将看到ASP.NET会给表单填加上去。看上去就像这样:

<form name="_ctl0" method="post" action="page.aspx" id="_ctl0">
...some code
...一些代码
</form>

 


Submitting a Form
提交表单

A form is most often submitted by clicking on a button. The Button server control in ASP.NET has the following format:
表单绝大部分通过点击按钮进行提交。在ASP.NET中Button服务器控件遵循以下格式:

<asp:Button id="id" text="label" OnClick="sub" runat="server" />

The id attribute defines a unique name for the button and the text attribute assigns a label to the button. The onClick event handler specifies a named subroutine to execute.
id属性定义了一个唯一的名称来对应的按钮,并且text属性会分配给按钮一个标签。onClick事件处理器指定一个被命名的子程序来执行

In the following example we declare a Button control in an .aspx file. A button click runs a subroutine which changes the text on the button:
在下面的举例里将在一个.aspx文件中声明一个Button控件。按钮按下后将执行子程序来改变按钮的文字:

Example(查看举例)

评论 (1) 1 All

登陆 | 还没注册?