We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

toolbar button question

Is there a way to make a toolbar button call javascript or pop up a new window with the URL?

Thanks!

3 Replies

SS Suresh Sekarean Syncfusion Team September 25, 2007 03:22 PM UTC

Hi Stephanie,

Client side java script routines can be executed using the property "ClientSideOnItemSelect" of an ToolBar Item. Please refer the below code snippet.

[C#]

ToolBar1.ClientSideOnItemSelect = "OnItemSelect()";

[Client JScript]



Also page navigation can be done on Item select using navigate URL property of ToolBarItem.

[C#]

ToolBarItem1.NavigateUrl = "http://www.syncfusion.com";

//Set control Target to '_blank' to navigate the page in new window. '_self' -Navigate in the same //window. 'Frame_name' -Navigate to the particular frame.
ToolBar1.Target = "_blank";

Please let us know if you need more info.

Regards,
Sureshsekaran.



GU Guadalupe March 22, 2019 09:01 PM UTC

Hello
It is possible in asp.net?


CI Christopher Issac Sunder K Syncfusion Team March 26, 2019 09:46 AM UTC

Hi Guadalupe,  

Yes, navigation to an URL through Toolbar click is possible in Asp.Net. We suggest you to bind client side click event for Toolbar and include the code for navigation in JavaScript as shown below 

<ej:Toolbar ID="editingToolbar" runat="server" ClientSideOnClick="OnItemSelect"> 
                <Items> 
                    <ej:ToolbarItem Id="google"  TooltipText="Google" Text="Google"></ej:ToolbarItem> 
                    <ej:ToolbarItem Id="firefox" TooltipText="FireFox" Text="FireFox"></ej:ToolbarItem> 
                    <ej:ToolbarItem Id="safari"  TooltipText="Safari" Text="Safari"></ej:ToolbarItem> 
                    <ej:ToolbarItem Id="opera"  TooltipText="Opera" Text="Opera"></ej:ToolbarItem> 
                </Items> 
   </ej:Toolbar> 
    <script> 
        function OnItemSelect(args) { 
            if (args.text == "Google") 
                window.open('http://www.google.com','_blank' ) // makes it open in a new window; 
        } 
    </script> 

This will open a new chrome tab when “Google” toolbar item is clicked.  


Please get back to us if you require any further assistance. 

Thanks, 
Christo 


Loader.
Live Chat Icon For mobile
Up arrow icon