2012-09-04 58 views

回答

1

在你的頁面加載,你可以添加

button.Attributes.Add("onclick", "confirm('are you sure? blah!')"); 
1

的asp:ButtonField字段>標籤不具有的OnClientClick。 boundbutton

應用「BTN-刪除的CssClass屬性:

與模板化的按鈕

<script type="text/javascript"> 
    function function() 
    { 
     return confirm("Are you sure you want to delete this?"); 
    } 
</script> 

... 

<asp:TemplateField> 
    <ItemTemplate> 
    <asp:ImageButton ID="button" runat="server" 
     OnClientClick="return function();" /> 
    </ItemTemplate> 
</asp:TemplateField> 
+0

我有。所以標籤不支持OnClientClick屬性。任何解決方案 – Jd30814

+0

我給你很容易的選擇 –

0

我發現這樣做的相當簡單的方式使用jQuery這意味着我仍然可以使用ASP工作時更換'到綁定按鈕(在這種情況下)然後添加以下jQuery腳本

$(function() { 
     $('.btn-remove a').attr('onclick', 'return confirm(\'Are you sure you want to delete this?\')'); 
    }); 
相關問題