How to pass parameter to OnClientClick function?

1 Answer 7 Views
Button
Matthew
Top achievements
Rank 1
Matthew asked on 28 Aug 2025, 08:47 AM | edited on 28 Aug 2025, 08:49 AM

How can I pass the number to the confirm popup message like

===============================

    Confirm to Delete Record ___(No)___?  

===============================

 

CODE in .aspx

<script>

function DeleteConfirm(sender, args) {
            args.set_cancel(!confirm('Confirm to Delete?'));
     } 

</script>

 

<telerik:RadButton ID="btnDelete" runat="server" Skin="Windows7" Text="Delete" CommandName="Delete"
         CommandArgument='<%# Eval("CueId") + "|" + Eval("RevID") + "|" + Eval("No") %>' OnClientClicking="DeleteConfirm"                               visible='<%# If(Eval("AdminPage").ToString() = "Yes", true, false) %>'  
         Enabled='<%# If(Eval("ControlStatus").ToString() = "R", true, false) %>' >
</telerik:RadButton>

 

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 28 Aug 2025, 09:29 AM

Hi Matthew,

To display the specific number ("No") from your data in the confirm popup message, you can extract it from the CommandArgument property of the RadButton in your JavaScript function. The sender parameter in the OnClientClicking event refers to the client-side RadButton object, and you can use its get_commandArgument() method to retrieve the value.

Here’s how to update your function:

function DeleteConfirm(sender, args) {
    var commandArgument = sender.get_commandArgument(); // "CueId|RevID|No"
    var parts = commandArgument.split('|');
    var recordNo = parts[2]; // "No" value

    var message = 'Confirm to Delete Record ' + recordNo + '?';
    if (!confirm(message)) {
        args.set_cancel(true);
    }
}

How this works:

  • sender.get_commandArgument() gets the string you set in the CommandArgument property.
  • .split('|') separates the values, so you can access the third value (parts[2]) which is your "No".
  • The confirm dialog will show the message with the specific record number each time the button is clicked.

This approach will dynamically display the number in your confirm popup as you need.

    Regards,
    Rumen
    Progress Telerik

    Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
    Tags
    Button
    Asked by
    Matthew
    Top achievements
    Rank 1
    Answers by
    Rumen
    Telerik team
    Share this question
    or