Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i used the below code in my application,it show the authenticate screen when user click yes and it also shows authenticate screen when the user click cancel

i want the
authenticate 
screen only when the user press yes

What I have tried:

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


<li><asp:LinkButton ID="lnk_Delete" runat="server"  OnClientClick="javascript:Confirm();javascript:return OpenSwipWindowAction('Delete','')"><img src="../images/Document_Delete.png" alt="" />Delete</asp:LinkButton></li>


Dim confirmValue As String

ElseIf hdnModuleName.Value = "Delete" Then
                confirmValue = Request.Form("confirm_value")
                If confirmValue = "Yes" Then
                    Label12.Text = "yes"
                Else

                    Label12.Text = "No"
                End If
Posted
Updated 3-Mar-17 1:32am
Comments
Bryian Tan 3-Mar-17 7:26am    
what the purpose of OpenSwipWindowAction('Delete','')? Execute after confirm?
ManiLancer 3-Mar-17 7:27am    
its a authenticate screen, if user click yes it will ask for password
ManiLancer 3-Mar-17 7:28am    
i want to execute the openswipwindowaction only when the confirm method returns yes
Bryian Tan 3-Mar-17 7:32am    
ok, see below, but the naming is a bit odd, "delete"

1 solution

I think this is how the code should look like
On button click prompt confirm
ASP.NET
<asp:LinkButton ID="lnk_Delete" runat="server"  
        OnClientClick="return Confirm();">
        <img src="../images/Document_Delete.png" alt="" />Delete</asp:LinkButton>


If yes, set hidden value and call return OpenSwipWindowAction (...) (Assuming it return true | false)
else (Cancel), return false, do nothing ( I'm assuming )
JavaScript
<script>
        function Confirm() {
            var confirm_value = document.createElement("INPUT");
            confirm_value.type = "hidden";
            confirm_value.name = "confirm_value";
            if (confirm("Do you want to Delete data?")) {
                confirm_value.value = "Yes";

                document.forms[0].appendChild(confirm_value);

                return OpenSwipWindowAction('Delete', '');
                
            } else {
                confirm_value.value = "No";
                return false;
            }

            document.forms[0].appendChild(confirm_value);
        }
    </script>
 
Share this answer
 
v3
Comments
ManiLancer 3-Mar-17 7:34am    
but the OpenSwipWindowAction('Delete', ''); is in usercontrol properties, how can i do that
Bryian Tan 3-Mar-17 7:40am    
How was it working before? Instead of calling the OpenSwipWindowAction('Delete', ''); onClientClick, I moved that function into Confirm()
ManiLancer 3-Mar-17 7:42am    
its working fine thanks dude..
Bryian Tan 3-Mar-17 7:44am    
You're welcome.
Karthik_Mahalingam 3-Mar-17 12:58pm    
if it works, please click accept answer to close this post.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900