Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ToolBar > how to add an onClick event to a toolbarButton from clientside

Not answered how to add an onClick event to a toolbarButton from clientside

Feed from this thread
  • Brian Garson avatar

    Posted on Jan 9, 2012 (permalink)

    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)");

    Reply

  • Brian Garson avatar

    Posted on Jan 9, 2012 (permalink)

    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);
    ...
    }

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ToolBar > how to add an onClick event to a toolbarButton from clientside
Related resources for "how to add an onClick event to a toolbarButton from clientside"

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