当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP.NET > ASP.NET - 按钮控件

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 - 按钮控件


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

The Button control is used to display a push button.
按钮控件可用来显示按钮。


The Button Control
按钮控件

The Button control is used to display a push button. The push button may be a submit button or a command button. By default, this control is a submit button.
按钮控件可用来显示按钮。按钮可以是提交按钮或是一个命令按钮。默认情况下这个控件是一个提交按钮。

A submit button does not have a command name and it posts the page back to the server when it is clicked. It is possible to write an event handler to control the actions performed when the submit button is clicked.
提交按钮不需要命令名称并且当它点击时会将提交的页面返回到服务器。当提交按钮点击时可以写事件处理器来控制行动的执行。

A command button has a command name and allows you to create multiple Button controls on a page. It is possible to write an event handler to control the actions performed when the command button is clicked.
命令按钮需要有命令的名称并且可以在一张页面上建立多个按钮控件。当命令按钮按下时可以写事件处理器来控制行动的执行。

The Button control's attributes and properties are listed in our web controls reference page.
有关按钮控件的所有属性都罗列在我们的WEB控件参考页上了

The example below demonstrates a simple Button control:
下面的举例演示了简单的按钮控件:

<html>
<body>

<form runat="server">
<asp:Button id="b1" Text="Submit" runat="server" />
</form>
</body>
</html>

 


Add a Script
添加脚本

A form is most often submitted by clicking on a button.
表单通常是通过点击按钮来进行提交的。

In the following example we declare one TextBox control, one Button control, and one Label control in an .aspx file. When the submit button is triggered, the submit subroutine is executed. The submit subroutine writes a text to the Label control:
在下面的举例中我们将在一个.aspx文件中声明一个文本框控件,一个按钮控件以及一个标签控件。当提交按钮被触发,提交子程序将被执行。提交子程序会在标签控件上写一些文字:

<script runat="server">
Sub submit(sender As Object, e As EventArgs)
lbl1.Text="Your name is " & txt1.Text
End Sub
</script>
<html>
<body>
<form runat="server">
Enter your name:
<asp:TextBox id="txt1" runat="server" />
<asp:Button OnClick="submit" Text="Submit" runat="server" />
<p><asp:Label id="lbl1" runat="server" /></p>
</form>
</body>
</html>

Example(举例)

评论 (1) 1 All

登陆 | 还没注册?