RadGrid for ASP.NET

Confirmation dialogs Send comments on this topic.
AJAX > What you should have in mind > Confirmation dialogs

Glossary Item Box

In case you would like to display a confirmation dialog to prompt the user whether the selected action should be executed or not, there are two possible scenarios:

  • In the standard mode, when Telerik RadGrid performs postbacks, you will invoke the confirm javascript method. 
  • When Telerik RadGrid works in AJAX mode the same approach is still applicable - you merely need to return false from the OnClientClick handler in case the user chooses negative option from the confirmation dialog 

Here is an example usage:

ASPX/ASCX Copy Code
<rad:RadGrid ID="RadGrid1" runat="server" DataSourceID="AccessDataSource1"
 
OnNeedDataSource="RadGrid1_NeedDataSource" EnableAJAX="true">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="CustomerID" DataSourceID="AccessDataSource1">
 
<Columns>
  
<rad:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True"
   
SortExpression="CustomerID" UniqueName="CustomerID">
  
</rad:GridBoundColumn>
  
<rad:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName"
   
UniqueName="CompanyName">
  
</rad:GridBoundColumn>
  
<rad:GridBoundColumn DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName"
   
UniqueName="ContactName">
  
</rad:GridBoundColumn>
    
<rad:GridTemplateColumn UniqueName="TemplateColumn">
       
<ItemTemplate>
         
<asp:ImageButton ID="ImageButton1" runat="server" AlternateText="Delete Customer"
          
OnClientClick="javascript:if(!confirm('This action will delete the selected customer and all of his/her orders.
            
Are you sure?')){return false;}"
          
ImageUrl="~/RadControls/Grid/Skins/Default/Delete.gif" />
        
</ItemTemplate>
    
</rad:GridTemplateColumn>
 
</Columns>
</MasterTableView>
</
rad:RadGrid>

The result form the code above, you can see on the screenshot below:

 Confirmation dialog