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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:22:08+00:00 2026-06-08T23:22:08+00:00

I am using Client script for confirm message box as follows string script =

  • 0

I am using Client script for confirm message box as follows

 string script = "fadeScript";
                ScriptManager.RegisterClientScriptBlock(this.Page, script.GetType(), "Script", "Closewindow();", true);

java script function:

<script type="text/javascript">
    function Closewindow() {
        var Result = confirm("Are you sure want to delete?");
        alert(Result);
        if (Result == true) {
            document.getElementById('txtConfirmresult').value = Result;//assigning to hidden text box 
            alert(txtConfirmresult.value);
        return true;
        }
    else 
    {
        document.getElementById('txtConfirmresult').value = Result;//assigning to hidden text box 
        alert('BYE');
         return false;
        }
}

</script>

I want to use the script return value in .cs file to excite procedure if it returns true. if it return false i have to stay on that particular page only. plz kindly help me on this

  • 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-08T23:22:09+00:00Added an answer on June 8, 2026 at 11:22 pm

    You can use __doPostBack(target, argument) to post back to the server. You can then evaluate __EVENTTARGET and __EVENTARGUMENT in the post data to see what you sent back and perform logic appropriately. Here is a link that provides a little more in depth information.

    A quick example:

    Script/Client side:

    <script type="text/javascript">
        function Closewindow() {
            var Result = confirm("Are you sure want to delete?");
            alert(Result);
            if (Result == true) {
                var txtConfirmResult = document.getElementById('txtConfirmresult');
                txtConfirmResult.value = Result;//assigning to hidden text box 
                alert(txtConfirmresult.value); //displaying for debug purposes
                __doPostBack( 'txtConfirmresult', Result ); //sending back to server.
            return true;
            }
        else 
        {
            document.getElementById('txtConfirmresult').value = Result;//assigning to hidden text box 
            alert('BYE');
             return false;
            }
    }
    

    C#

        protected void Page_Load(object sender, EventArgs e)
        {
            string target =  Request["__EVENTTARGET"];
            string argument = Request["__EVENTARGUMENT"];
    
            if (target != null && target.Equals( "txtConfirmresult" ) )
            {
                 this.DoSomeGreatServerSideProcessing(argument);
            }
        }
    

    Updated to add slightly more correct variable names, but should work with your existing codebase assuming your script was working. I would be very careful using txtConfirmresult as your ID as that will only work if runat="server" is not set on the textbox. If that is the case, the ID will be prepended to denote container hierarchy.

    I would suggest naming your “callbacks” very well, such as:

    Script/Client side:

    <script type="text/javascript">
        function Closewindow() {
            var Result = confirm("Are you sure want to delete?");
            document.getElementById('txtConfirmresult').value = Result;//assigning to hidden text box 
            if (Result) {
    
                __doPostBack( 'UserConfirmedFormSubmission', "CloseWindow" ); //sending back to server.
                return true;
            }
            else 
            { 
               return false;
            }
    }
    

    C#

        protected void Page_Load(object sender, EventArgs e)
        {
            string target = Request["__EVENTTARGET"];
            string argument = Request["__EVENTARGUMENT"];
    
            if (!string.IsNullOrEmpty(target) && target.Equals("UserConfirmedFormSubmission"))
            {
                 if ( !string.IsNullOrEmpty(argument) && argument.equals("CloseWindow"))
                 {
                    this.HandleUserRequestedCloseWinow();
                 }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is the unity js script support for socket client using javascript ? or any
hello i am using this Page.ClientScript.RegisterStartupScript() to call a javascript function from vb code
How can I get the query string from the browser url using client side
We are using Google Analytics for our site, but since it uses client script
I installed this JavaScript project which attempts to obtain the user's geolocation using client-side
I'm using this script ( http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ ) to valdate my form etc, which also
I am struggling converting image to byte array using client side script. I have
This client side script is being added to buttons in our existing codebase. It
I have a client script on a page, that calls a dynamic script generated
Using tortoiseSVN client side hook script for pre-commit, we are trying to run some

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.