Click here to Skip to main content
15,904,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,
I am using VS 2005,C#.net,ASP.NET.
I have a web application.
When clicking of a button,I need to get one confirmation message .
If it is yes, then second confirmation message has to come.
IF second is yes One function in C# server side code has to be executed

Thanks in advance
Geroge
Posted

Hey there,

Check this simple example to achieve what you want:
ASP.NET
<asp:button id="Button1" runat="server" text="Click me" onclick="Button1_Click" onclientclick="return Confirmation();" xmlns:asp="#unknown" />

JavaScript
function Confirmation() {
                if (confirm("OK for next confirm")) {
                    if (confirm("OK for postback event")) {
                        return true;
                    }
                }
                return false;
            }


Let me know if it helps.

Azee...
 
Share this answer
 
You can use JavaScript confirm box
You need to add confirm box on OnClientClick event of button .when a user response to first confirm box then catch the result of first confirm box .pop up second confirm according to response .
save second confirm box values in hidden field and use that to execute your C# function in code behind

suppose you have one hiddenfield name hdnconfirm

In your aspx file
XML
<asp:Button ID="btnInvoke" runat="server" Text="Click"
                    onclick="btnInvoke_Click" OnClientClick="return confirmation();" />
<asp:HiddenField ID = "hdnconfirm" runat="server" Visible="true" />





in head section of your asp page

XML
<script type="text/javascript" language="javascript">
       function confirmation() {
           var FirstConfirmResult = confirm("Click yes to proceed else Cancel");
           if (FirstConfirmResult == true) 
           {
             var SecondConfirmResult =   confirm("This is second confirm box ");
            
              if (SecondConfirmResult == true )
               {
               

                    document.getElementById('hdnconfirm').value = "Yes";
                
               }
              else 
              {
                document.getElementById('hdnconfirm').value = "No";
              }
            
           }
       }


   </script>





Use this hdnconfirm.value in code behind to execute your function


C#
protected void btnInvoke_Click(object sender, EventArgs e)
   {
     

       if (hdnconfirm.value == "Yes")
       {
          
              Do some processing here
       }
   }


Hope This is what you need !
 
Share this answer
 
v2

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