A very very strange problem. I have RadContextMenu that are identical working on two page, but failing on another page. It was working fine and then just stopped giving a "contextMenu.show is not a function" error in javascript.
Here is the code
<p> Touch the <asp:Button OnClientClick="javascript:HelpExplainSelected(event)" runat="server" CssClass='EditP' UseSubmitBehavior="False"/> buttons to access menus for creating form fields.</p>
I add RadCodeBlock on the suggestion of another post with a similar problem
<telerik:RadCodeBlock ID="RadCodeBlockMenu" runat="server"><script type="text/javascript"> function HelpExplainSelected(event) { var contextMenu = document.getElementById("<%= HelpExplainMenu.ClientID %>"); contextMenu.show(event); }
<telerik:RadContextMenu ID="HelpExplainMenu" CssClass="RadContextMenu1" runat="server"> <ExpandAnimation Type="None" Duration="0" /> <CollapseAnimation Type="None" Duration="0" /> <DataBindings> <telerik:RadMenuItemBinding /> </DataBindings> <Items> <telerik:RadMenuItem Text="Edit the Properties" PostBack="False" ></telerik:RadMenuItem> <telerik:RadMenuItem Text="Add a Form Row for some Type" PostBack="False" ></telerik:RadMenuItem> <telerik:RadMenuItem Text="Insert a Form Row of Another Type" PostBack="False" ></telerik:RadMenuItem> <telerik:RadMenuItem Text="Remove the Form Row" PostBack="False" ></telerik:RadMenuItem> </Items></telerik:RadContextMenu>
This exact code works fine on two pages but on the third page, gives the function show() an error on contextMenu.show(event) that show is not found.
I tried re-starting Visual Studio, rebooting the computer. Solutions that have fixed other flaky Telerik problems. I stare endlessly the code in the working and not working page, but it the same, except for the RadCodeBlock.
In the HTML generated for the menu (in all three pages),
<div tabindex="0" id="ctl00_MainContent_HelpExplainMenu"> <div class="RadMenu RadMenu_MetroTouch RadMenu_Context RadMenu_MetroTouch_Context RadContextMenu1"> <ul class="rmActive rmVertical rmGroup rmLevel1"> <li class="rmItem rmFirst"><a class="rmLink" href="#"><span class="rmText">Edit the Properties</span></a></li><li class="rmItem "><a class="rmLink" href="#"><span class="rmText">Add a Form Row for some Type</span></a></li><li class="rmItem "><a class="rmLink" href="#"><span class="rmText">Insert a Form Row of Another Type</span></a></li><li class="rmItem rmLast"><a class="rmLink" href="#"><span class="rmText">Remove the Form Row</span></a></li> </ul> </div><input id="ctl00_MainContent_HelpExplainMenu_ClientState" name="ctl00_MainContent_HelpExplainMenu_ClientState" type="hidden" /></div>
HelpExplainMenu is a div. How does the div object get a Show function? What plumbing can be broken? Ideas on how to debug it? Every example I can find uses EventArgs with eventArgs.get_domEvent(); to get the event, could this be an issue? If so how should a anchor supposed to open a RadContextMenu.
It was working and died with no apparent reason, will the other pages die in time too? Programming is not supposed to be like this.
Please do not ask for a project with the problem, off course it will not be possible since it does work fine elsewhere.
Please suggest how to debug this.
