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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:38:47+00:00 2026-06-15T06:38:47+00:00

I have a LinkButton which only needs to postback when the Ajax-Call inside the

  • 0

I have a LinkButton which only needs to postback when the Ajax-Call inside the delete function fails.
The ajax-call calls a Webmethod which throws an exception if the deletion of the rows failed for some reason.
When i throw the exception the ajax call reaches the “error”-branch (as expected). But when the “deleteSelectedRows” function returns false, the postback is not being stopped.
How can i archieve this?

<asp:LinkButton ID="Delete" ClientIDMode="Static" runat="server" Text="Delete" OnClientClick="return deleteSelectedRows()" ></asp:LinkButton>

//the jquery code
function deleteSelectedRows() {
        //get selected rows
        var selectedRows = ... getting ids ...

        var postData = "{ 'IDs':'" + selectedRows + "'}";
        var url = "WebMethods.aspx/DeleteRows";
        var status= jQuery.ajax({
            url: url,
            dataType: "html",
            async: false,
            type: "POST",
            data: postData,
            contentType: "application/json; charset=utf-8",
            success: function (msg) {
                return true;//continue postback
            },
            error: function (err) {
                jQuery.jGrowl('Fehler: Auftragspositionen konnten nicht gelöscht werden! Möglicherweise existieren bereits Transaktionen zu dieser Auftragsposition.');
                //e.preventDefault();
                return false;//stop postback
            }
        });
        return status.status == 200;//true when delete worked, false otherwise
    }

EDIT: This works when i use a asp:Button instead of asp:Linkbutton… but i dont have a clue why?!

  • 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-15T06:38:48+00:00Added an answer on June 15, 2026 at 6:38 am

    ok, i solved it:
    the problem was due to the following code which i used to stop execution of links if they are disabled (maybe this is useful for someone else too, so i post it here):

    jQuery('.btn[onclick]').each(function () {
        //override onclick so i can check if the link is disabled before execution
        jQuery(this).data('onclick', this.onclick);
    
        this.onclick = function (event) {
            if (jQuery(this).hasClass('aspNetDisabled')) { //disabled link
                return false;//prevent execution
            };
    
            //execute link
            jQuery(this).data('onclick').call(this, event || window.event);
        };
    });
    

    i changed this to, and now its working:

    jQuery('.btn[onclick]').each(function () {
        //override onclick so i can check if the link is disabled before execution
        jQuery(this).data('onclick', this.onclick);
    
        this.onclick = function (event) {
            if (jQuery(this).hasClass('aspNetDisabled')) { //disabled link
                return false;//prevent execution
            };
    
            //execute link
            var boolVal = jQuery(this).data('onclick').call(this, event || window.event);
            return boolVal;
        };
    });
    

    i have to admit, that the question couldnt be solved with the information i provided!

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

Sidebar

Related Questions

I have an asp:LinkButton which require following - - call jQuery to open link
I have a function which sets my linkbutton as the default button for a
I have a gridview within an updatepanel which allows paging and has a linkbutton
i have Linkbutton inside updatePanel and when i click on it it returns following
I have a webform which contains some LinkButtons. When each LinkButton is clicked I
I have a gridview inside an update panel.In that gridview, I have a linkbutton
So I have this FormView which should only have 1 record for editing: <asp:FormView
the question says it all : i have a linkbutton to which i pass
I have a LinkButton inside an UpdatePanel that I do not want the client
I have a gridview which is like <asp:TemplateField HeaderText=File Name SortExpression=FileName> <ItemTemplate> <asp:LinkButton ID=lnkname

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.