Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > FileExplorer > How to prevent firing server side methods after client side validation fails

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

Feed from this thread
  • Praveen avatar

    Posted on Dec 2, 2011 (permalink)

    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.

    Reply

  • Dobromir Dobromir admin's avatar

    Posted on Dec 5, 2011 (permalink)

    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

    Reply

  • Robert Fuess avatar

    Posted on Dec 12, 2011 (permalink)

    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)?

    Reply

  • Robert Fuess avatar

    Posted on Dec 13, 2011 (permalink)

    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..

    Reply

  • Dobromir Dobromir admin's avatar

    Posted on Dec 14, 2011 (permalink)

    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > FileExplorer > How to prevent firing server side methods after client side validation fails
Related resources for "How to prevent firing server side methods after client side validation fails"

ASP.NET FileExplorer Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]