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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:19:16+00:00 2026-06-09T17:19:16+00:00

I am facing a problem with buttons. I want a client side validation to

  • 0

I am facing a problem with buttons.

I want a client side validation to occur(say selecting a maximum of only 4 checkboxes in a datalist).

I used a INPUT TYPE=”BUTTON” RUNAT=”SERVER” style of tag. and put Onserverclick=”someservermethod” which works fine.

I wrote a Validate() and added onclick=”return validate();” to the above HTML markup and was thinking if it returns false then my server side code someservermethod() would not execute and it works great as expected

But when I return true I thought it would fire my someservermethod(), but it is not working. Any thoughts on why it is not working?

HTML MARKUP BELOW FOR THE BUTTON

button onclick="return ValidateSelection();" type="button" id="btnSubmit"
                runat="server" onserverclick="btnSubmit_Click"

JAVASCRIPT CODE

function ValidateSelection()
{
  if(good)
  {
    // I expect that my server side code btn_Submit would have got called. But
    // it doesn't get called.
    return true;
  }
  else
  {
    //This works great. Not calling the server side method for the button
    alert('something happened');
    return false;
  }  
}

I think I am messing up with the formatting. Pardon 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-09T17:19:18+00:00Added an answer on June 9, 2026 at 5:19 pm

    The control you are using right now it HtmlButton which is not “fit” for what you are trying to do, as your onclick overwrites the required client side code for the post back.

    What you need is the Button control which does support overwriting the client side onclick and still perform the post back as usual.

    Change the markup to this and it should work:

    <asp:button OnClientClick="return ValidateSelection();" id="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit"></asp:Button>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam facing problem in understanding and converting a matlab code into opencv. I want
I am facing problem to get variable from query string. I have used htaccess
In my application i want to do bluetooth chat. I'm facing a problem in
Edit: I've come to realize the main problem I'm facing is that I want
I am facing a problem of adding overlays. I want to add button which
I have exactly 5 buttons in my layout. The problem i am facing while
I am facing problem with UIPanGestureRecognizer. suppose i am adding 10 button dynamicaly using
I am facing a problem while disabling the command button after one click. I
iam facing problem in passing array to view. this is my controller code.. function
I am facing problem while setting focus in EdiText. Below is my EditText property.

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.