This is a migrated thread and some comments may be shown as answers.

Confirm not working

2 Answers 61 Views
Window
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 2
Bill asked on 06 Oct 2010, 02:19 AM

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 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 06 Oct 2010, 08:06 AM
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
0
Bill
Top achievements
Rank 2
answered on 06 Oct 2010, 03:53 PM
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>

Tags
Window
Asked by
Bill
Top achievements
Rank 2
Answers by
Georgi Tunev
Telerik team
Bill
Top achievements
Rank 2
Share this question
or