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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:20:28+00:00 2026-06-18T04:20:28+00:00

I have to resolve a problem in some code assigned to me and the

  • 0

I have to resolve a problem in some code assigned to me and the problem is that following this code in page.init else statemant:

Me.SaveChangesButton.Attributes.Add("OnClick", 
    "if (!confirm('Are you sure?')){
        return false;
     } else {
        document.getElementById('SaveChangesButton').disabled = true; 
        document.getElementById('rejectButton').disabled = true;
     }
")

overrides this code:

Protected Sub SaveChangesButton_Click(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles SaveChangesButton.Click

Question [edited]

  1. How can I bind confirm() to button so that it doesn’t override my handler function?
  2. Where in the code would it be best practice to bind it?
  3. If I remove second part else {document.getElementById('SaveChangesButton').disabled =
    true; document.getElementById('rejectButton').disabled = true;}
    it works correctly, but how should I write it so it continues to execute SaveChangesButton_Click, as I understand only the second part overrides handler?
  4. How can I execute those two lines document.getElementById('SaveChangesButton').disabled = true;
    document.getElementById('rejectButton').disabled = true;
    and still execute SaveChangesButton_Click handler without overriding it?
  • 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-18T04:20:29+00:00Added an answer on June 18, 2026 at 4:20 am

    1) You should use OnClientClick:

    Me.SaveChangesButton.OnClientClick = @"
        if (!confirm('Are you sure?')) {
            return false;
        } else {
            document.getElementById('SaveChangesButton').disabled = true; 
            document.getElementById('rejectButton').disabled = true;
        }"
    

    2) If you bind the SaveChangesButton_Click in the Page.Init, I would then set the OnClientClick too.

    3,4) The OnClientClick fires (sort of) before the server side OnClick (of course). This makes you disabling your button, before firing the OnClick. And OnClick won’t fire on a disabled button. What to do? Delay disabling your button.

    Me.SaveChangesButton.OnClientClick = @"
    if (!confirm('Are you sure?')) {
        return false;
    } else {
        setTimeout(function(){
            document.getElementById('SaveChangesButton').disabled = true; 
            document.getElementById('rejectButton').disabled = true;
        }, 100);
    }"
    

    And this actually makes your question a duplicate of this one…

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

Sidebar

Related Questions

I have produced some VBA code to resolve this problem : Private Sub Workbook_SheetChange(ByVal
I have a problem that I can't resolve. Let's say I have this map
I have some trivial code that looks like this: SortedDictionary<String, long> d = new
I have a common problem with ORACLE in following example code: create or replace
Problem I have a piece of java code (JDK 1.6.0._22 if relevant) that implements
Can't figure out how to resolve following problem: I have a few actors (workers)
i have some problem in scala to resolve implicit values, and i have the
I am having a problem with some code. I have looked across the web
I have some c++ code that is a snap-in for a MMC based application.
i have one textfield for input some serial number code.i want set this code

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.