Hi all,
I want to call a server-side routine when a menu item is clicked, and have tried using the following code (extract):
I want to call a server-side routine when a menu item is clicked, and have tried using the following code (extract):
| <telerik:RadScriptBlock ID="cb1" runat="server"> |
| function InitiateAjaxRequest(arguments) |
| { |
| var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>"); |
| ajaxManager.ajaxRequest(arguments); |
| } |
| function emailMenuClicked(sender, args) |
| { |
| var itemValue = args.get_item().get_value(); |
| if (args.get_item().get_text() == "Email Customer") |
| { |
| InitiateAjaxRequest("EmailCustomer",1); |
| } |
| if (args.get_item().get_text() == "Email Officer") |
| { |
| InitiateAjaxRequest("EmailOfficer",2); |
| } |
| } |
| </telerik:RadScriptBlock> |
| <telerik:RadContextMenu ID="RadContextMenu1" runat="server" EnableEmbeddedSkins="False" |
| Skin="Glastir" OnClientItemClicked="emailMenuClicked"> |
| <Items> |
| <telerik:RadMenuItem runat="server" Text="Email Customer"> |
| </telerik:RadMenuItem> |
| <telerik:RadMenuItem runat="server" Text="Email Officer"> |
| </telerik:RadMenuItem> |
| </Items> |
| <Targets> |
| <telerik:ContextMenuControlTarget ControlID="RadScheduler1" /> |
| </Targets> |
| </telerik:RadContextMenu> |
I need to put the Javascript in a RadScriptBlock because I need to evaluate the AjaxManager's client ID. However, when I do this, I get an 'object expected' error because the emailMenuClicked function is not visible to the RadContextMenu.
When I put the emailMenuClicked function in an ordinary <script></script> tag, then the code there can't see the InitiateAjaxRequest function.
I'm sure there's a simple solution, but I'm going round in circles on this - can someone point me in the right direction, please?
Thanks,
James