码迷,mamicode.com
首页 > 其他好文 > 详细

Attributes

时间:2018-04-30 15:36:23      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:protected   对话框   style   web   void   没有   自动   text   onclick   

 

  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

标签:protected   对话框   style   web   void   没有   自动   text   onclick   

原文地址:https://www.cnblogs.com/zzzz07/p/8973598.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!