禁用aspx页面中的按钮

时间:2011-02-02 14:20:50

标签: asp.net

我正在尝试禁用aspx格式的按钮。这有效:

btnSave.Attributes.Add(
    "onclick",
    "this.disabled=true;this.value='Saving...';needToConfirm=false;" +
    ClientScript.GetPostBackEventReference(btnSave, "").ToString());

但是表单上有两个按钮,我想禁用它们。这不起作用:

btnSave.Attributes.Add(
    "onclick",
    "this.disabled=true;this.value='Saving...';document.getElementById(<%=btnDelete.ClientID %>).disableneedToConfirm=false;" +
    ClientScript.GetPostBackEventReference(btnSave, "").ToString());

1 个答案:

答案 0 :(得分:0)

你在这里的btnsave-code中引用了btnDelete ..你应该把它改成 btnSave :)

btnSave.Attributes.Add("onclick", "this.disabled=true;this.value='Saving...';document.getElementById(<%= btnDelete.ClientID %>).disableneedToConfirm=false;" + ClientScript.GetPostBackEventReference(btnSave, "").ToString());