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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:30:15+00:00 2026-06-17T05:30:15+00:00

I am calling a javascript function to return yes,no values from the user in

  • 0

I am calling a javascript function to return yes,no values from the user in a button click event inside an update panel. I want to call certain server side functions depending on user action (yes/no). My javascript code is given below

function Confirm() {
        var confirm_value = document.createElement("INPUT");
        confirm_value.type = "hidden";
        confirm_value.name = "confirm_value";
        if (confirm("Do you want to save data?")) {
            confirm_value.value = "Yes";
        } else {
            confirm_value.value = "No";
        }
        document.forms[0].appendChild(confirm_value);
    }

I am calling this in my server side button click which is shown below.

 if ((Convert.ToInt32(_dsLeaveDetails.Tables[0].Rows[0][0]) == 1) 
            {

                ShowAlert("Leave is already marked for this date");
                return;

            }
            else if ((Convert.ToInt32(_dsAttendanceDetails.Tables[0].Rows[0][0]) >= 1)) 
            {

                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "Confirm();", true);
                string confirmValue = Request.Form["confirm_value"];
                if (confirmValue == "Yes")
                {
                      ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('You clicked YES!');", true);
                }
                else
                {
                  ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('You clicked YES!');", true);
                }


                return;
            }

The issue is, pop up is showing only after the code is fully executed and because of that user action (yes/no) cannot be processed further.
Also I cannot call javascript function on clientclick event because immediately I dont require a pop up. Only after checking the dataset dsAttendanceDetails, I need the pop up. Kindly help.

  • 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-17T05:30:16+00:00Added an answer on June 17, 2026 at 5:30 am

    You seems to assume that the line ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "Confirm();", true); would execute the java-script function immediately – but that’s simply not possible. This call would execute the JS function when response reaches to the client i.e. when subsequent server code would have been already executed.

    The java-script function would be executed at the client side and you will need a form submit (sync or asynchronous does not matter) to retrieve the user’s choice at the server side. So you need to two requests – first would register the script that would confirm user choice and subsequent request to send the user’s choice to the server.

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

Sidebar

Related Questions

Here i am calling a javascript function on a button click and i need
I am calling a Javascript function in my html page from a Flash movie
Possible Duplicate: calling ASP function from javascript okay running this code : <script type=text/javascript>
I'm calling some JavaScript from within my PHP code, but I want the second
Hi have always trouble with calling JavaScript function with parameters values as values bonded
When calling a function in my views/helpers/ file, from my script inside views/scripts/ ,
I am calling a javascript function from .cs file which is as below: private
This is related to a question I've asked previously: Calling Javascript function after loading
I'm calling the JavaScript function onsubmit of form but form has submit before finished
I have a javascript function for checking errors which I am calling on OnClicentClick

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.