I want to apply javascript on asp:buttonfield
, when click on button then display message.
Like Delete Button confirm message.
asp:ButtonField> tag does not have an OnClientClick.
Replace with Templated button
<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>
In your page load, you could add
button.Attributes.Add("onclick", "confirm('are you sure? blah!')");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With