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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:33:49+00:00 2026-05-23T22:33:49+00:00

I have a LinkButton where I use the OnClientClick property to ask the user

  • 0

I have a LinkButton where I use the OnClientClick property to ask the user whether he really wants to perform an action, e.g:

<script>
function confirmDelete() {
  return confirm('Do you really want to delete?');
}
</script>

<asp:LinkButton runat="server" OnClientClick="return confirmDelete()" ... />

This pattern usually works, but on this specific page, it doesn’t. No matter whether I click OK or Cancel in the confirm dialog, the postback is executed.


Just for completeness (to answer pst’s question): the rendered HTML is OK. E.g. it looks like this:

<a id="ctl00_c1_content_btnDelete" onclick="return confirmDelete();"
 href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(..))"
... >
  Delete
</a>
  • 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-23T22:33:51+00:00Added an answer on May 23, 2026 at 10:33 pm

    The reason for the behavior was another piece of javascript, where a handler for the link(button)’s click event was registered via jquery, e.g. something similar to this:

    <script>
    $(document).ready(function() {
      $('a').click(function() {
        // ...
        return (someCondition == true);
      });
    });
    </script>
    

    It seems this click-handler was called after the one registered by OnClientClick, and when this one returned true, then the postback occurred, independent of the result of the first click-handler (the confirm dialog).

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

Sidebar

Related Questions

how can i use request.querystring in asp.net.i have a linkbutton and this is in
I have an ASP.NET linkbutton control on my form. I would like to use
I have a LinkButton that has to postback to perform some logic. Once it
i have created Array of Linkbutton and when user click on link button it
i have set enableviewstate property of linkbutton and label to true.also regenrating same buttons
I have an action column in my repeater which shows actions a user can
I use yui datatable in my asp.net application... I have a link button in
i have Linkbutton inside updatePanel and when i click on it it returns following
In gridview's column i have a linkbutton and a label under it. I want
I have a gridview within an updatepanel which allows paging and has a linkbutton

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.