标签: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‘)"); }
实验证明如果把名换为别的名字就是不好使的但不知道为什么
标签:protected 对话框 style web void 没有 自动 text onclick
原文地址:https://www.cnblogs.com/zzzz07/p/8973598.html