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 7844239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:48:53+00:00 2026-06-02T16:48:53+00:00

In my asp.net application am having a master page and some other pages, in

  • 0

In my asp.net application am having a master page and some other pages, in that pages I’ve add button as well as delete button, for this delete button I’ve written the delete method in my code behind, its working fine. But before this delete function fires I need to display a delete confirmation box. For this I’ve written delete confirmation method in the jQuery file named custom.js under Js folder, and am referring this js file in the master page like

<script src="/Js/custom.js" type="text/javascript"></script>

in this custom.js I’ve written the delete confirmation method under pageInit of custom.js like

function pageInit(){
$(".delete").click(function (event) {
    confirmationBox(event);
    });
}

function confirmationBox(event) {

var r = confirm("You are about to delete some items. Click Ok to continue");
if (r == true) {
    $(document).submit();
}
else {
    event.preventDefault();
}
}

and in the scripting am using the class name as delete like

<asp:Button ID="btnDelete" class="delete" Text="Delete"/>

from the script am calling the js file as

<script type="text/javascript">
 $(document).ready(function () {
     pageInit();
 });
 </script>

but this delete confirmation method is not firing at all, whats wrong with this query, can anyone help me…..

  • 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-02T16:48:54+00:00Added an answer on June 2, 2026 at 4:48 pm

    Another way to implement what you are doing is by using the OnClientClick event of the ASP.NET Button

    <asp:Button 
         ID="btnDelete" 
         class="delete" 
         Text="Delete" 
         OnClientClick="return confirmationBox()" />
    

    function confirmationBox() {
        var r = confirm("You are about to delete some items. Click Ok to continue");
            if (r) {
                return true;
            }
            else {
                return false;
            }
        }
    

    and that should do it 🙂

    [Update]
    My bad, I forgot to include return on the OnClientClick function;
    the return stops the postback from happening if you choose cancel on the confirmation.

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

Sidebar

Related Questions

I am using master page and child pages in asp.net application. I am having
I am working with an ASP.NET MVC application. I have one master page having
ASP.NET Application I am having some confusion with showing images. IE is fully working
I'm having trouble loading JQueryUI from Google's CDN. I've got an ASP.NET application that
I'm having a problem with an ASP.NET MVC application that I'm developing. I'm still
I am having some problems using UpdatePanels in my C#/ASP.NET application. I shall post
I am having some trouble with one of my ASP.NET 2.0 application's connection string.
Hi i'm having problems with this. I am developing an asp.net mvc 2 application.
I have an old .net 2005 web site that has some asp pages and
I am doing an asp.net mvc application having a Data Access Layer (DAL). Having

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.