how to add an onClick event to a toolbarButton from clientside

2 posts, 0 answers
  1. Brian Garson
    Brian Garson avatar
    54 posts
    Member since:
    Jan 2008

    Posted 09 Jan 2012 Link to this post

    Hello,

    Haven't been able to find any documentation and it looks like my only option is to set a command name and command argument for a button, but I'm trying to work around this.  Any ideas?

    var toolBar = $find("<%= m.ClientID %>");
    var button = toolBar.findItemByText("Get Button");
    button.enable();
    //want to do something like this:
    button.click("openWindow(1)");
  2. Brian Garson
    Brian Garson avatar
    54 posts
    Member since:
    Jan 2008

    Posted 09 Jan 2012 Link to this post

    ended up just going with the commandName and Argument and adding a handler to the toolbar but only on this page that it's used on (since toolbar is part of master pages)

    shared in case someone else stumbles upon this post

    function OnClickedHandler_Custom(sender,args)
            {
                var command = args.get_item().get_value();
                var argument = args.get_item().get_commandArgument();
                if(command == "PreviewShare")
                {
                    openPreviewWindow(argument);
                }
                else if(command == "ShareSettings")
                {
                    openSharingSettings(argument);
                }
                  
            }
      
            function myFunction(myId) {
                var toolBar = $find("<%= m.ClientID %>");
                toolBar.add_buttonClicked(OnClickedHandler_Custom);
                
                //set up preview button          
                var buttonPreview = toolBar.findItemByText("Preview & Share");
                buttonPreview.enable();
                buttonPreview.set_commandName("PreviewShare");
                buttonPreview.set_commandArgument(myId);
    ...
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top