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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:49:05+00:00 2026-06-14T19:49:05+00:00

I’m developing an asp.net application and I need to call a confirm dialog box

  • 0

I’m developing an asp.net application and I need to call a confirm dialog box on the code behind. And after that, I need to get the user’s click (if he clicked at OK or Cancel).

If he clicked the OK button of the dialog, I must continue to running the code where I stopped before call the dialog.

To solve this problem I thought in put at the aspx an input of type button, and set it’s style to visibility:hide. So, when the users click on the OK button the programm will call this hidden button which calls a method that will continue the job stopped.

I’ll post my code, I expect it might help.

The code below is on my code behind, and it calls the confirm dialog.

System.Web.UI.
    ScriptManager.RegisterClientScriptBlock(this, GetType(), "__Mensagem", "if (confirm('" + CustomMessage + "')){document.getElementById(\'<%=btnSave.ClientID%>\').click();}", true); 

The code below is on my aspx, it’s the “hidden” button.

<input style="visibility:hidden;" id="btnSave" runat="server" onclick="btnSave_Click"/>

I don’t know why isn’t working. The error that I receive after click on the button OK of the confirm dialog box is the following: Erro em tempo de execução do Microsoft JScript: ‘document.getElementByID(…)’ é nulo ou não é um objeto

I’m from Brazil so the error is in portuguese, a translation to english it’s something like this:

“A runtime error occurred on Microsoft JScript ‘document.getElementByID(…)’ is null or is not an object”

I give a look at the html code of the page and I notice that the button isn’t there.

Maybe it’s because I’m using an UpdatePanel, but when I removed it (just for tests, I must use the Update Panel), the same error is showed, and in this time the button were on the page’s html code.

  • 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-14T19:49:06+00:00Added an answer on June 14, 2026 at 7:49 pm

    I solved the problem replacing the part

    document.getElementById(\'<%=btnSave.ClientID%>\').click();
    

    by

    $(\"#ctl00_body_btnSave\").click();
    

    I also replace the input element by an asp:Button.

    Give a look how my code is on my code behind now:

    System.Web.UI.
        ScriptManager.RegisterClientScriptBlock(this, GetType(), "__Mensagem", "if (confirm('" + CustomMessage+ "')){$(\"#" + btnSave.ClientID + "\").click();}", true);
    

    And on my aspx:

    <asp:Button id="btnSave" Width="0px" Text="" runat="server" onclick="btnSave_Click"/>
    

    The use of Widht=”0px” and Text=”” to hidden the button isn’t recommended, but I used because it won’t cause me problems. It’s recommended the use of a CssClass which make it hide.

    So, if the user confirm the operation, the even btnSave_Click is called.

    Thanks for all the answers.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.