1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Javascript Function Call from RadMenu

Javascript Function Call from RadMenu

6 posts, 0 answered
  1. Johan Lausbcher
    Johan Lausbcher avatar
    10 posts
    Registered:
    08 Jul 2009
    13 Jul 2009
    Link to this post
    HI there

    I'm relatively new to Sitefinity ,
    and I would like to know if it is possible to somehow access a RadMenu Item's "href" properties from within Sitefinity in order to do a simple call to a javascript function.

    I have tried to use the OnClientItemClicked property in the RadMenu Edit propeties but with no luck,

    The only good resource i can find is from the Telerik support on the RadMenu Control itself and how to use Clientside events etc...from within an aspx page,  but i want to find a way from within Sitefinity after i have dropped a RadMenu control in my page

    Are there any other ways to access the individual MenuItem properties inside the radMenu Control,in order to change their link behaviours...
    But bottomline is :  If i click on a radMenu item , I want a javascript function to be called...

    thanks for any help

    Johan Laubscher
    BlueAnt Web





  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    14 Jul 2009
    Link to this post
    Hello Johan Lausbcher,

    You can use the Site Menu user control, which is available in the Sitefinity's toolbox.
    You can subscribe for the client event OnClientItemClicking. You can take a look at the following example implementation - Menu / Client-side Events. The markup for the SiteMapMenu is located in 
    [~your site]/Sitefinity/UserControls/Navigation35/SiteMenu.ascx

    I hope this helps you.

    Regards,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. Johan Lausbcher
    Johan Lausbcher avatar
    10 posts
    Registered:
    08 Jul 2009
    14 Jul 2009
    Link to this post
    Hi Parvan

    Thanks for the reply

    I actually have seen the same example before, but i'm struggling more from the Sitefinity property side of things , to get that Javascript function to be called and executed.

    I have tried to use the OnClientClicking property within the Site Menu properties of the SiteMenu Control, but still doesnt work, maybe i'm just doing something wrong,
    And what exactly do you mean by subscribing to the OnClientClicking event ?
    Is there a setting or something that has to be enabled or setup before one can use Client SIde events?

    I can easily get to call the Javascript function from a generic control , but thats because i can do it the usual way within the HTML code of the generic control,
    This is what is so frustrating for me , is becasue it is soemthing i'm used to do evry easily the conventional way, but with Sitefinity who is supposed to do it for you(because of the user-friendly/novice/client-with-no-website-building -knowledge-skills perpsective), it's really hard to figure out where and how to do this...

    Your furher help on this will be appreciated , thanks

    Johan


  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jul 2009
    Link to this post
    Hello Johan Lausbcher,

    Here is a sample code that illustrates using of RadMenu with some code that is fired on OnClientItemClicking. All RadControls work in Sitefinity in the same way that they work in other ASP.NET website application.

    <script type="text/javascript"
        function onClicking(sender, eventArgs) { 
            var item = eventArgs.get_item(); 
            var navigateUrl = item.get_navigateUrl(); 
            if (navigateUrl && navigateUrl != "#") { 
                var proceed = confirm("Click yes to proceed to" + navigateUrl); 
            } 
            if (!proceed) { 
                eventArgs.set_cancel(true); 
            } 
            else { 
                eventArgs.set_cancel(false); 
            } 
        } 
        </script> 
      
      
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />  
    <telerik:RadMenu OnClientItemClicking="onClicking" ID="RadMenu1" runat="server"  DataSourceID="SitemapDataSource1" OnItemDataBound="RadMenu1_ItemDataBound">  
    </telerik:RadMenu>  

    I have tried to use the OnClientClicking property within the Site Menu properties of the SiteMenu Control

    The property works properly. You need to have the OnClientItemClicking function defined in the control template. Then from the properties section of the RadMenu you can set this function.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Johan Lausbcher
    Johan Lausbcher avatar
    10 posts
    Registered:
    08 Jul 2009
    14 Jul 2009
    Link to this post
    Hi Guys

    Thanks a lot , i got it to work, after i placed my function within the Control template of the control and not have them on the Master page.

    I have another question though, can i implement the same with the RadWindow control, because i've noticed or can't seem to find the RadWindow control template .ascx file. anywhere in my website's folders.

    I basically want to again call a function that will show a RadWindow...
    can one use the same approach or is that done diffrently?

    I appreciate your help

    johan
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jul 2009
    Link to this post
    Hello Johan Lausbcher,

    Below is an example that shows how to open a new RadWindow on button click event.

    <script type="text/javascript"
     
         function OpenWindow() { 
               
             var manager = GetRadWindowManager(); 
             manager.open(null, "RadWindow1"); 
         } 
      
     </script> 
      
     <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
       <Windows> 
           <telerik:RadWindow 
               ID="RadWindow1" 
               runat="server" 
               NavigateUrl="http://www.telerik.com"
           </telerik:RadWindow> 
       </Windows> 
    </telerik:RadWindowManager> 
     
    <button onclick="OpenWindow();return false;" style="width: 190px">Show window</button> 

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
6 posts, 0 answered