Results 1 to 2 of 2

Thread: how to get return value of JQuery confirmation dialog from server side code?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    782

    how to get return value of JQuery confirmation dialog from server side code?

    Dear All,

    I have JQuery confirmation dialog function that called by server side code (C#)
    how to get its return value of that function? in this case the return value would be either Yes or No..
    please help

    Thanks a lot in advance & Regards
    Win

    I called it in button clicked event as below:

    Code:
    protected void btn1_Click(object sender, EventArgs e)
    {
        string message = "Message from server side, please select yes or no";
        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowConfirmation('" + message + "');", true);
    }
    my question is how to get JQuery return value, in this case the return value would be Yes or No?

    Code:
    === JQuery Confirmation Dialog ==
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
    <link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
    rel="stylesheet" type="text/css" />
    <script type="text/javascript">
    function ShowConfirmation(message) {
                    $(function () {
                        $("#dialog").html(message);
                        $("#dialog").dialog({
                            title: "Please Confirm",
                            buttons: {
                                Yes: function () {
                                    alert('yes');
                                    $(this).dialog('close');
                                }, No: function () {
                                    alert('no');
                                    $(this).dialog('close');
                                }
                            },
                            modal: true
                        });
                    });
                };
    </script>

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    Re: how to get return value of JQuery confirmation dialog from server side code?

    I don't mean to be picky but your confirm box is not "called" from server side.

    The RegisterStartupScript method simply injects the specified script into the rendered page.
    The ShowConfirmation script is run after the button click event has finished executing and the page is rendered so if you want to get the result of the Confirmation box in the button click event you can't .

    The confirm box is called from the scripting engine in the browser at the time the page is loaded.

    So what do you want to do with the return value, and will that be server side or client script side?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width