How to prevent firing server side methods after client side validation fails

7 posts, 0 answers
  1. Praveen
    Praveen avatar
    14 posts
    Member since:
    Oct 2011

    Posted 02 Dec 2011 Link to this post

    Hi,

    I am using radfileexplorer (35 version telerik dll) through a custom provider.I have used some client side functions (eg :onCreatenewfolder,onMovedirectory..etc) to perform foldername,length validation folder's existance checking etc..While doing these,
    if any validation is failed , i set args.setCancel(true),return false; statements ;even though server side provider methods (eg: CreateDirectory,MoveDirecory ) firing automatically based on the desired actions.How to prevent these event firing?.Please help me by sending exact code.

    Regards,
    Praveen.
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 05 Dec 2011 Link to this post

    Hi Praveen,

    To prevent firing a server-side functionality you need to cancel the corresponding client-side event (as you have tried). In order to correctly cancel client-side event you need to call set_cancel(true) (not args.setCancel(true)) method in the event handler.

    Could you please correct this error and see if the execution is canceled properly?

    Regards,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Robert Fuess
    Robert Fuess avatar
    6 posts
    Member since:
    Jul 2009

    Posted 12 Dec 2011 Link to this post

    Very interesting.  I am working on similar issues.

    Are your examples in http://www.telerik.com/help/aspnet-ajax/fileexplorer-client-side-events.html incorrect?  They show using args.set_cancel(true);

    When would we use args.set_cancel(true) and when just set_cancel(true)?
  5. Robert Fuess
    Robert Fuess avatar
    6 posts
    Member since:
    Jul 2009

    Posted 13 Dec 2011 Link to this post

    I just tried using set_cancel(true)
    This gets a javascript Undefined error...

    The args.set_cancel(true) doesnt get this Undefined error - but doesnt cancel the postback... Any ideas?

    I'm trying to do some javascript validation in OnClientCreateNewFolder.  If validation fails (like a folder with that name exists... or invalid characters) , I dont want to create the folder.  I dont want the client script to continue on..
  6. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 14 Dec 2011 Link to this post

    Hi Robert,

    Please accept my apologies for not being clear enough in my previous post.

    The correct way to prevent execution of a client-side event (that is cancelable) is to call set_cancel() method of the arguments object, e.g.:
    args.set_cancel(true)

    Regarding the issue that you experience, I am not quite sure I understand the exact case. Creating a new folder does not trigger a postback. Do you have custom implementation of this functionality? If so, could you please provide a sample page demonstrating the issue so we can investigate it further?

    All the best,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  7. Shiv
    Shiv avatar
    1 posts
    Member since:
    Aug 2016

    Posted 22 Aug in reply to Dobromir Link to this post

    Hello Team,

    Its urgent ...we are uisng current version of telerik controls..and i want to firing the server side event when cleint side validation fails.

    I have used eventArgs.set_cancel(true);,but it says undefined error.

    could you please tell me fast.

     

  8. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 22 Aug Link to this post

    Hi Shiv,

    I am afraid that the exact scenario you want to achieve is not clear for me. Can you elaborate a bit on:
    • which are the exact server-side events you are trying to prevent and
    • which are the exact client-side events you are to canceling?

    Regards,
    Vessy
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017