网络学院 w3pop社区 网络资源 IT新闻

w3pop.com :: 网络学院 :: ASP.NET :: ASP.NET Web 表单

会员登陆

帐号

密码

回答

记住密码

忘记密码? 注册

ASP.NET
ASP.NET中 Bin,Ap..
C#中new和overrid..
ASP.NET 2.0 - Na..
ASP.NET 2.0 - Ma..
ASP.NET 2.0 新特..
ASP.NET - Databa..
ASP.NET - The Da..
ASP.NET - Repeat..
ASP.NET - XML 文..
ASP.NET - The So..
ASP.NET - The Ha..
ASP.NET - The Ar..
ASP.NET - Data B..
ASP.NET - 按钮控..
ASP.NET - TextBo..
ASP.NET 维持浏览..
ASP.NET Web 表单
ASP.NET - 事件
ASP.NET - 服务器..
asp.net的网页

ASP.NET Web 表单


作者:w3schools 翻译/整理:w3pop.com 发布:2007-08-03 浏览:2461 :: ::

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(查看举例)

评论 (0) All