confirm - asp.net c#

javascript Thailand
  • 12 years ago

    I have this codes to confirm if the user wants to continue. If the user clicks OK, I want it to go to btnLogOut_Click(). Want code will I add to my javascript?

    In my .aspx code behind:
    btnLogout.Attributes.Add("onclick", "return ConfirmLogOut();");

    In my .aspx (in masterpage, actually)
    <script type="text/javascript">
    <!--
    function ConfirmLogOut() {
     var answer = confirm("Are you sure you want to Log Out?")
     if (answer){
      WHAT HERE?
     }
     else{
      alert("Cancelled transaction.")
     }
    }
    //-->
    </script>

    Kindly help.. Thanks in advance... Smiley Face

  • 12 years ago

    use this code

    if(answer)

    return true;

    else

    return false; 

  • 12 years ago

    thanks.. somebody else gave a suggestion to use OnClientClick instead of javascript since i'm using asp.net..

    thanks again for the reply..

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An expert is a man who has made all the mistakes that can be made in a very narrow field” - Niels Bohr