Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
275
confirm
posted

Hello

i have the following in the page load - if not ispostback.

btndelete.Attributes.Add(

"onclick", "if(confirm('Are you sure to delete?')){}else{oEvent.cancelPostBack = true;}")

the code fires on both the Ok and Cancel button clicks. how can i trap if the user clicks the Cancel? basically I just want a confirmation window.

thanks

Parents
No Data
Reply
  • 275
    Suggested Answer
    posted

    here is the answer for anyone coming across the same issue

    1) properties - Turn off AutoSubmit

    2) place the javascript in the main page
    <script language ="javascript">
    function showconfirmbox() {
    var button = ig_getWebControlById("WebImageButton1");
    if (confirm('This will DELETE the selected record from the database. Are you sure you want to delete ?' )) {
    button._autoSubmit =true;}
    else
     {
    button._autoSubmit = false;}}
    </script>

    3) code behind file aspx.vb
    Me.WebImageButton1.ClientSideEvents.Click = "showconfirmbox"

     

Children
No Data