Attributes

Posted zzzz07

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Attributes相关的知识,希望对你有一定的参考价值。

 

  confirm() 方法用于显示一个带有指定消息和 OK 及取消按钮的对话框。

Attributes是指是属性的集合,位于using Systems.Web.UI.htmlControls下,用于获取在ASP.NET页内的服务器空间标记上表示的所有属性名称和值对的集合。

 

<form id="form1" runat="server">
    <div>
    <asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click"/>
    </div>
    </form>

 

 protected void Button1_Click(object sender, EventArgs e)
    {
        Button1.Attributes.Add("onclick","confirm(‘1‘)"); //添加一对儿属性,名值对
        Button1.Attributes.Remove("onclick");//什么效果都没有,因为移除这个属性的名字,自动的也就移除了值
        Button1.Attributes.Add("onclick", "confirm(‘2‘)");
    }

 

 实验证明如果把名换为别的名字就是不好使的但不知道为什么

 

以上是关于Attributes的主要内容,如果未能解决你的问题,请参考以下文章

Mvc总结-特性(Attributes)

无法制作应用:…属性可在xml文件中使用

类型“DispatchQueue.Attributes”没有成员“序列”

Boost Log : Attributes

asp.net 一个页面有两个iframe 在代码中可以控制第一个iframe的Attributes["src"] 但是第二个就不好用了

特性(Attributes)