Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:11:12+00:00 2026-06-17T15:11:12+00:00

I have return one Javascript function which asks the confirm message to the user.

  • 0

I have return one Javascript function which asks the confirm message to the user.
The JavaScript functions is

    function ConfirmOnDelete() {
    if (confirm("Are you sure to delete?"))
        return true;
    else
        return false;

and GridView is like below:

    <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />

Here I want to call the JavaScript function when user clicking the Delete in the GridView Command Field.
How to call this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:11:13+00:00Added an answer on June 17, 2026 at 3:11 pm

    Assuming you want to keep using your CommandField, you could do this programmatically using your GridView’s OnRowDataBound event.

    Specify the event handler for the RowDataBound event in your GridView declaration:

    <asp:GridView ID="gv" runat="server" OnRowDataBound="gv_RowDataBound"....
    

    Then in your event handler (code-behind) find your button (here I’m assuming ImageButton, though this depends on your ButtonType property in your CommandField) and add JavaScript to its OnClientClick property.

    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ((ImageButton)e.Row.Cells[cell].Controls[ctrl]).OnClientClick = "return confirm('Are you sure you want to delete?');"; // add any JS you want here
        }
    }
    

    In the above example, cell refers to the column index of your CommandField and ctrl refers to the control index (Delete button) within the cell you’re referencing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everybody, I have a one HTML page which contain one Javascript function which shows
I've been writing a javascript function which returns true if the value matches one
I have a javascript function which redirects user to a diff page. It goes
I have one method in my managed bean which returns javascript as a string.
I have a function which takes in two parameters, and returns one or the
So i have a form, and onsubmit=return reg_check(this) where reg_check() is a javascript function
I have the following javascript function for rounding: function round(val, numberdigits){ return Math.round(val*Math.pow(10, numberdigits))/Math.pow(10,
There is a JavaScript function, of which I have zero control of the code,
i have one jquery function which i need to work in following way 1.
I have the following function which constructs one or more y-axes for a Highcharts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.