confirm - 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?
      alert("Cancelled transaction.")

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

  • 12 years ago

    use this code


    return true;


    return false; 

  • 12 years ago

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

    thanks again for the reply..

Post a reply

Enter your message below

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


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