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

  • Home
  • SEARCH
  • 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 949727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:26:52+00:00 2026-05-15T23:26:52+00:00

I have the next code to work on ASP.Net controls. I’m trying to add

  • 0

I have the next code to work on ASP.Net controls.

I’m trying to add some javascript code to “onclick” event on a button when the result variable(res) is equals to “NO”. The issue is that the first time it assigns the value to “onclick” it works fine, but when the removeAttr is executed and again the function is call and the res is equals to “NO” again it doesn’t add the code on “onclick” event. So what’s wrong on this? Thanks for your help. =)

Legend:
– HLevel(Textbox)
– PSave(LinkButton)

 $('#HLevel').blur(function () {
      // SOME CODE HERE BEFORE THE ISSUE CODE
      var res = $(msg).find("string").text();
      if (res == "NO") {
         $('#PSave').attr("onclick", "javascript:return confirm('some text');");
      } else {
        $('#PSave').removeAttr("onclick");
      }

  });
  • 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-15T23:26:53+00:00Added an answer on May 15, 2026 at 11:26 pm

    Use the unbind() and click() methods:

    if (res == "NO") {
        $('#PSave').click(function() {return confirm('some text');});
    } else {
        $('#PSave').unbind("click");
    }
    

    If you use jQuery, try to make use of it as much as possible and don’t mix styles.

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

Sidebar

Related Questions

I am trying to learn some ASP.NET MVC. Please bear with me but asp.net
I need to call ASP.Net server side code from the client. Because I'm in
I have successfully implemented my GridView now, but, as always, the whole ASP.NET life
In a proof-of-concept project I'm working on, I have a generic abstract class that
I have a problem with animations using jQuery on nested tables. I want to
In my simple starter asp page I create a DataTable and populate it with
Sorry for a badly-phrased question. I have a requirement coming from a non-technical person
Question: What is the best way to set focus to a web control in
I am working on a winforms application using LINQ to SQL - and am

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.