TreeView & ContextMenu & PostBack

4 posts, 0 answers
  1. Gilles
    Gilles avatar
    3 posts
    Member since:
    Jun 2010

    Posted 01 Apr Link to this post

    Hi, sorry my english isn't very good, hope you understand.

    I have a treeview with a contextMenu. In the contextMenu I have an item that needs some javascript to run and a confirmation to know if postback must be triggered.

    Something like this :

    - user right-click on a node (contextMenu appears)

    - user select menu item

    - javascript stop postback (I used "args.set_cancel(true);" in the javascript)

    - javascript runs some functions then a "modal window" is displayed (this is not a window.confirm !!!) with a message like "Are you sure ?" and the usual buttons "yes/no"

    My problem, how do I re-enable (or resume, or resend) the "postback" like if the menu item was clicked ?

    I've already done something like this on a RadButton, and simply by using "sender.click()" in the javascript, the postback is "resumed". But there are no functions like this on a contextMenu I think...

     

  2. Gilles
    Gilles avatar
    3 posts
    Member since:
    Jun 2010

    Posted 01 Apr Link to this post

    After some more research, I can get the menuItem and perform a click in my javascript (menuItem.click()) but nothing happens... no postback... what am I missing ?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gilles
    Gilles avatar
    3 posts
    Member since:
    Jun 2010

    Posted 01 Apr Link to this post

    Finally... of course my javascript was in onClientContextMenuItemClicking, but when I fired "menuItem.click()" it cames back in onClientContextMenuItemClicking... 
    Problem solved (perhaps not the best way.. but solved...)
  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 05 Apr Link to this post

    Hello Gilles,

    The MenuItem's click() method is the correct method to use if you want to invoke a click. This will fire the corresponding events (ItemClicking including) as if the Item is clicked with the mouse. You can find more information on the MenuItem object's client-side methods in the following documentation article.

    Regards,
    Ivan Danchev
    Telerik
    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