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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:37:52+00:00 2026-05-27T12:37:52+00:00

When Delete button is clicked, the confirmation box should pop up if the selected

  • 0

When Delete button is clicked, the confirmation box should pop up if the selected node has child nodes. Otherwise, it should not do anything.

Right now, when I click on delete, it just deletes without confirming.

Here is the code:

  <asp:Button ID="btn_delete" runat="server" Height="32px" 
        onclick="btn_delete_Click"  OnClientClick = "return childnode();"                              
        Text="Delete" Visible="False"  />  

    <script type="text/javascript">
        function childnode() {
            var treeViewData = window["<%=nav_tree_items.ClientID%>" + "_Data"];

            var selectedNode = document.getElementById(treeViewData.selectedNodeID.value);
            if (selectedNode.childNodes.length > 0) {
                return confirm("heloo");
            }
            return false;
        }                                        
    </script>
  • 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-05-27T12:37:52+00:00Added an answer on May 27, 2026 at 12:37 pm

    You’ll need to return false from the function if you don’t want the button push to go through in some cases. Currently you are only returning a value from the function when calling confirm.

    If one or both of the if conditions fail, add a return false if you don’t want the event to bubble up activating the button/sending the form.


    Modification of your existing code

    function childnode() {
        var treeViewData = window["<%=nav_tree_items.ClientID%>" + "_Data"];
        if (treeViewData.selectedNodeID.value != "") {
            var selectedNode = document.getElementById(treeViewData.selectedNodeID.value);
            if (selectedNode.childNodes.length > 0) {
                return confirm("heloo");
            }   
    
            return false; // don't send form                                             
        }
    
        return false; // don't send form
    }  
    

    Is it still malfunctioning?

    1. Make sure that the logic inside your function is accurate, webbrowsers will often fail silently when trying to get a property of an undefined variable.

    2. In your definition of your button you have written OnClientClick = "return childnode();", try changing this to OnClientClick="return childnode();" and see if that might solve the problem.

    3. See if the event fires at all, OnClientClick="alert(123);".

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

Sidebar

Related Questions

I populate a DataGrid from a CollectionViewSource. Each row has a delete button. On
I have a <tr> which will be removed when clicked in delete button, but
I have a delete button in a gridview. For those not familiar with asp.net
I have a Gridview., usually, when the delete command button is clicked then the
I have a delete button on my web site which I want to add
...I want to Show the 'delete' button when user is an admin, and show
As soon as the user clicks the delete button my jQuery script asks the
I am getting this error when clicking the Delete button / link in a
I want to modify my table view cell apparence when the delete button came
I have a standard ASP.NET 2.0 web page with a Delete button on it.

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.