0

i Have button that shows confirmation dialog

<asp:Button ID="btnSignOff" runat="server" 
    CssClass="button" Text="Sign OFF"
    OnClick="btnSignOff_Click"
    OnClientClick="return confirm('Are you sure you want to Sign OFF?');"  
/>

the problem is even i clicked the cancel button, the page will reload and execute the server side code instead of nothing happen.

note: Were using INTERNET EXPLORER browser.

Weird scenario is when i tried to some client's machine with same browser it works fine. but in other client's machine its not working.

how can i check the accuracy of this code if some clients scenario is not working.

thanks in advance.

Jorge
  • 17,896
  • 19
  • 80
  • 126

3 Answers3

0
OnClientClick="if(confirm('Are you sure you want to Sign OFF?')) return true; else return false;"
redcat
  • 1
0
<script type="text/javascript">
        function Confirm1() {
            return confirm("Are you sure you want to Sign OFF?");
        }
    </script>

<asp:Button ID="btnSignOff" runat="server" 
    CssClass="button" Text="Sign OFF"
    OnClick="btnSignOff_Click"
    OnClientClick="return Confirm1()"
/>

works 100%

0

"Weird scenario is when i tried to some client's machine with same browser it works fine. but in other client's machine its not working."

Probably scripts are disabled in browser. make sure active script is enabled

check this

Community
  • 1
  • 1
voddy
  • 950
  • 1
  • 11
  • 21