Confirm Extender for ButtonField

E

Elmo Watson

I know how to add a confirmation or an AJAX extender to a regular button,
but is there any way to add a confirm (yes/no) to a ButtonField in a
Gridview?
 
M

Milosz Skalecki [MCAD]

Hi elmo,

Unfortunatelly you cannot use ButtonField with ConfirmButtonExtender without
extra coding, insead i'd recommend using templatefield:

<asp:GridView runat="server" ID="gv" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" ID="btnDelete" Text="Delete"
CommandName="Delete" />
<ajaxtoolkit:confirmbuttonextender id="cbe" runat="server"
targetcontrolid="btnDelete"
confirmtext="Are you sure you want to delete this record?" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


or even better, why not just using templatefield with a button (no
confirmbuttonextender needed):

<asp:GridView runat="server" ID="gv" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" ID="btnDelete"
Text="Delete"
CommandName="Delete" OnClientClick="return
confirm('really?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top