client side validation

2 posts, 0 answers
  1. Bharani Mani
    Bharani Mani avatar
    40 posts
    Member since:
    Dec 2009

    Posted 28 Dec 2009 Link to this post

    Hello,
             I m using RadToolBar.. I want to do a client side validation in OnClientButtonClicked() function.

     

    function OnClientToolBarButtonClicked(sender, eventArgs)

     

    {

     

    var button = eventArgs.get_item();

     

     

     

    if(button.get_text() == "Delete")

     

    {

     

    if(confirm("Are you sure you want to delete?"))

     

    {

     

    return true;

     

    }

     

    else

     

     

    return false;

     

    }

    }

    When the user presses ok then go ahead and delete otherwise return as we do in Javascript.

    Thanks,
    Bharani

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Dec 2009 Link to this post

    Hello Bharani,

    Attach ' OnClientButtonClicking ' event of RadToolBar and cancel the event using 'eventArgs.set_cancel(true);' method if confirm returns false.

    javascript:
     
        function OnClientButtonClicking(sender, eventArgs) { 
            var button = eventArgs.get_item(); 
            if (button.get_text() == "Delete") { 
                if (confirm("Are you sure you want to delete?")) { 
                    eventArgs.set_cancel(false); 
                } 
                else 
                    eventArgs.set_cancel(true); 
            } 
        } 

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top