ASP.NET 的 WebControl.Attributes 属性
2006-05-27 21:39
501 查看
WebControl.Attributes 属性
获取与控件的属性不对应的任意特性(只用于呈现)的集合。
[Visual Basic]
Public ReadOnly Property Attributes As AttributeCollection
[C#]
public AttributeCollection Attributes {get;}
[C++]
public: __property AttributeCollection* get_Attributes();
[JScript]
public function get Attributes() : AttributeCollection;
属性值
名称和值对的 System.Web.UI.AttributeCollection。
备注
Attributes 集合包含在 Web 服务器控件的开始标记中声明的所有属性的集合。这使您得以以编程方式控制与 Web 服务器控件关联的属性。您可以将属性添加到此集合或从此集合中移除属性。
注意 此属性用控件开始标记中集合中的所有属性来呈现,与浏览器设置无关。并非所有的浏览器都支持呈现的每个属性。不受支持的属性通常被浏览器忽略。
示例
[Visual Basic, C#, JScript] 下面的示例阐释当 TextBox 控件失去焦点时,可以如何使用 WebControl 的 Attributes 属性运行 Javascript 命令。
[Visual Basic]
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
TextBox1.Attributes("onblur") = "javascript:alert('Hello! Focus lost from text box!!');"
End Sub
</script>
</head>
<body>
<h3>Attributes Property of a Web Control</h3>
<form runat="server">
<asp:TextBox id="TextBox1" columns=54
Text="Click here and then tap out of this text box"
runat="server"/>
</form>
</body>
</html>
[C#]
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e) {
TextBox1.Attributes["onblur"]="javascript:alert('Hello! Focus lost from text box!!');";
}
</script>
</head>
<body>
<h3>Attributes Property of a Web Control</h3>
<form runat="server">
<asp:TextBox id="TextBox1" columns=54
Text="Click here and then tap out of this text box"
runat="server"/>
</form>
</body>
</html>
获取与控件的属性不对应的任意特性(只用于呈现)的集合。
[Visual Basic]
Public ReadOnly Property Attributes As AttributeCollection
[C#]
public AttributeCollection Attributes {get;}
[C++]
public: __property AttributeCollection* get_Attributes();
[JScript]
public function get Attributes() : AttributeCollection;
属性值
名称和值对的 System.Web.UI.AttributeCollection。
备注
Attributes 集合包含在 Web 服务器控件的开始标记中声明的所有属性的集合。这使您得以以编程方式控制与 Web 服务器控件关联的属性。您可以将属性添加到此集合或从此集合中移除属性。
注意 此属性用控件开始标记中集合中的所有属性来呈现,与浏览器设置无关。并非所有的浏览器都支持呈现的每个属性。不受支持的属性通常被浏览器忽略。
示例
[Visual Basic, C#, JScript] 下面的示例阐释当 TextBox 控件失去焦点时,可以如何使用 WebControl 的 Attributes 属性运行 Javascript 命令。
[Visual Basic]
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
TextBox1.Attributes("onblur") = "javascript:alert('Hello! Focus lost from text box!!');"
End Sub
</script>
</head>
<body>
<h3>Attributes Property of a Web Control</h3>
<form runat="server">
<asp:TextBox id="TextBox1" columns=54
Text="Click here and then tap out of this text box"
runat="server"/>
</form>
</body>
</html>
[C#]
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e) {
TextBox1.Attributes["onblur"]="javascript:alert('Hello! Focus lost from text box!!');";
}
</script>
</head>
<body>
<h3>Attributes Property of a Web Control</h3>
<form runat="server">
<asp:TextBox id="TextBox1" columns=54
Text="Click here and then tap out of this text box"
runat="server"/>
</form>
</body>
</html>
相关文章推荐
- Asp.net web Control Enable 属性设置
- Asp.net web Control Enable 属性设置
- 利用 HttpModule,基于输出,统一控制、干预、处理(例如: 过滤关键字、AntiXSS) ASP.Net WebForm Control 展现属性的方案原型
- Web Server Controls->ASP.NET ImageButton Control
- 在asp.net中为Web用户控件添加属性(转)
- ASP.NET System.Web.HttpContext类Current属性
- ASP.NET的Web.Config 节点的属性设置说明
- ASP.NET:CustomAutoCompleteTextBoxWebControl[WithSourceCode]
- 指定HTML标签属性 |Specifying HTML Attributes| 在视图中生成输出URL |高级路由特性 | 精通ASP-NET-MVC-5-弗瑞曼
- 在ASP.NET WebService 中如何使用 WebMethod 属性
- asp.net中转换web user control为custom web control
- [导入][ASP.NET 控件实作 Day16] 继承 WebControl 实作 Toolbar 控件
- Asp.net Attributes添加额外属性
- 在asp.net中为Web用户控件添加属性和事件
- 在asp.net中为Web用户控件添加属性和事件
- Web Server Controls->ASP.NET CheckBox Control
- Web Server Controls->ASP.NET Label Control
- Web Server Controls->ASP.NET RadioButton Control
- 使用ASP.NET Web服务代理的URL行为属性
- Web Control开发随笔(1):ASP.NET 页面的生命周期