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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:53:09+00:00 2026-05-22T02:53:09+00:00

I have a grid control that allows users to add a value into the

  • 0

I have a grid control that allows users to add a value into the grid.

It produces the following link for inserting a brand new item.

<a onclick="if(!$find('radGridHolidays_ctl00').insertItem()) return false;" id="radGridHolidays_ctl00_ctl02_ctl02_PerformInsertButton" href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("radGridHolidays$ctl00$ctl02$ctl02$PerformInsertButton", "", true, "", "", false, true))'>Insert</a>

I have some custom jQuery code that validates textboxes before the submit. I am trying to prevent the link from submitting the __doPostBack, but my code isn’t working.

    // if need be, move this to its own .js file
    String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

    // Document loaded, let's register some validation
    $(function() {

        $('#holidayValidationDisplay').hide();

        $('a#radGridHolidays_ctl00_ctl02_ctl02_PerformInsertButton').click(function(e) {

            e.stopImmediatePropagation();
            e.preventDefault();
            var hasErrors = false;

            // alert('You clicked me!');
            var holidayName = $('#radGridHolidays_ctl00_ctl02_ctl02_validatorHolidayName').val().trim();
            var holidayDate = $('#radGridHolidays_ctl00_ctl02_ctl02_RDIPHolidayDate_dateInput_text').val().trim();

            if (holidayName.length == 0) {
                hasErrors = true;
                $('#holidayList').append('<li>You must provide a holiday name</li>');
            }

            if (holidayDate.length == 0) {
                hasErrors = true;
                $('#holidayList').append('<li>You must provide a holiday date</li>');
            }

            if (hasErrors) {
                $('#holidayValidationDisplay').show();
                return false;
            }
        });
    });

but the link is still firing off when I don’t want the postback to occur if there are errors. I saw something about preventing it to work in an UpdatePanel, but I’m not sure that the solution there applies to my scenario.

If anyone has any ideas, I’m all “ears”.

  • 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-22T02:53:10+00:00Added an answer on May 22, 2026 at 2:53 am

    I believe the issue you’re having is that the button has no knowledge if the form is valid or not. This is what I do:

    Write a custom function that returns true or false based on some other value:

    function isTermsChecked(oSrc, args)
    {
        args.IsValid = $("#chkTerms").is(':checked');
    }
    

    So in this example, if my terms checkbox is checked, then args.IsValid is true. Just go to the link properties and there should be a property called OnClientClick. You would put isTermsChecked.

    In your specific case, you would probably want to use a variable. If jQuery comes up invalid, set that variable to false, and the custom validation function will reference that variable. Essentially if it’s true, the button will proceed, false, and it won’t.

    EDIT: If you’re doing validation on each row, the issue that I see is if one row fails validation then my solution above will make all link buttons disabled until all validation on the grid has passed. You may want to forget the custom function and do this:

    If the jQuery validation fails, then find the link button in that row and add an OnClick attribute with the value return false then if validation passes, remove that attribute.

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

Sidebar

Related Questions

We have a grid control that allows a user to filter text in different
I have a grid and I need to dynamically replace a control that resides
I have a Data Grid View inside a control that is displayed in a
I have a user control that allows items to be added to it by
I have a control extending PropertyGrid which allows users to set the properties of
I have a Grid control that I'd like to set the margin properties of
I have a grid control that have a DataSource property as Object , Now
I have a grid view control in my application. Please see the below code.
I need a excel-like grid control in MFC, do anyone have good suggestion to
Is it possible to have something like Data Grid or Grid View control in

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.