Confirm not working

3 posts, 0 answers
  1. Bill
    Bill avatar
    175 posts
    Member since:
    Apr 2010

    Posted 05 Oct 2010 Link to this post

    In my button Save event, I have to ask the user if they have something else to do before they proceed with the save. The below js seems to execute, but doesn't return back to the event (and proceed) if I choose Cancel and I don't get my screen back if I answer OK. Am I doing something incorrect with the function?

    Here is my server side code inside the Save button event:

    <code>

    if (tsPatientDemographics.SelectedTab.Text == "Pri Ins")
                {
                    String s = "Sec_Ins()";
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "Secondary Insurance?", s, true);
                }

    </code>

    Here is my js code:

    <code>

    function Sec_Ins() {

        if (confirm("Is there Secondary or Tertiary Insurance information available?") == true) {
            selectSecTab();
            return false;
        }
        else
            return true;
    }

    function selectSecTab() {
        var tabStrip = $find("<%= tsPatientDemographics.ClientID %>");
        var tab = tabStrip.findTabByText("Sec Ins");
        tab.select();
    }

    </code>

  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 06 Oct 2010 Link to this post

    Hello William,

    In your code, you output a JavaScript code that will be run after the page postbacks. The code outputs a confirmation window, but after that you need to manually return it to the server - such behavior is expected as this is the way ASP.NET works. For example you could use __doPostBack() or if you are using RadAjax - RadAjax's ajaxRequest to send the result back to the server and continue with your logic in a separate function.


    Sincerely yours,
    Georgi Tunev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bill
    Bill avatar
    175 posts
    Member since:
    Apr 2010

    Posted 06 Oct 2010 Link to this post

    Georgi, as I thought about it some more, I place an onclientclick event of the submit button and the below js works perfectly.

    Here is the completed js code which works perfectly using the onclientclick event of the submit button.

    <code>

                function CheckForOtherIns() {

                    var tabStrip = $find("<%= tsPatientDemographics.ClientID %>");
                    var selectedTab = tabStrip.get_selectedTab();
                    var hdnOtherIns = document.getElementById("hdnOtherIns");

                    hdnOtherIns.value = "0";

                    if (selectedTab != null) {
                        var selectedTabValue = selectedTab.get_text();

                        if (selectedTabValue == "Pri Ins") {
                            if (confirm("Is there Secondary or Tertiary Insurance information available?")) {
                                selectSecTab();
                                hdnOtherIns.value = "1";
                                return false;
                            }
                            else {
                                return true;
                            }
                        }
                        else if (selectedTabValue == "Sec Ins")
                            if (confirm("Is there Tertiary Insurance information available?")) {
                            selectTerTab();
                            hdnOtherIns.value = "1";
                            return false;
                        }
                        else {
                            return true;
                        }
                    }
                }

                function selectSecTab() {
                    var tabStrip = $find("<%= tsPatientDemographics.ClientID %>");
                    var tab = tabStrip.findTabByText("Sec Ins");
                    tab.select();
                }

                function selectTerTab() {
                    var tabStrip = $find("<%= tsPatientDemographics.ClientID %>");
                    var tab = tabStrip.findTabByText("Ter Ins");
                    tab.select();
                }

    </code>

Back to Top