This is a migrated thread and some comments may be shown as answers.

Adding context menu dynamically giving error

1 Answer 31 Views
Menu
This is a migrated thread and some comments may be shown as answers.
shadow
Top achievements
Rank 2
shadow asked on 05 Nov 2012, 02:09 PM
I am trying to show a context menu on mouse over of an image control.

Below is my code

           
Dim ControlsContainer As New Panel
           Dim InfoIcon As New Image
           Dim InfoContextMenu As New RadContextMenu
           Dim mi As New RadMenuItem
 
 
 
 
 
 
           ControlsContainer.ID = "pnlInfoContainer"
 
 
 
 
           InfoIcon.ID = "InfoImageIcon"
           InfoIcon.ImageUrl = "/mb/admin/images/plus.png"
           InfoIcon.Attributes.Add("onmouseover", "ShowInfoMenuOnLeftClick();")
 
 
 
 
           InfoContextMenu.ID = "mb_InfoContents_ContentextMenu"
           InfoContextMenu.ClientIDMode = System.Web.UI.ClientIDMode.Static
 
 
 
 
           mi.Text = "Home"
           InfoContextMenu.Items.Add(mi)
 
 
 
 
           ControlsContainer.Controls.Add(InfoIcon)
           ControlsContainer.Controls.Add(InfoContextMenu)
 
 
 
 
           Dim script As String = "<script type=""text/javascript""> function ShowInfoMenuOnLeftClick(sender, args) {     var contextMenu = $find('mb_InfoContents_ContentextMenu'); console.log(contextMenu); contextMenu.show(args); } </script>"
           If Not Me.Page.ClientScript.IsStartupScriptRegistered("InfocontentsMenu") Then
               Me.Page.ClientScript.RegisterStartupScript(Me.Page.GetType, "InfocontentsMenu", script)
           End If
 
 
           Me.Controls.Add(ControlsContainer)
 
 
 
 
           Dim MenuTargetConfiguration As New ContextMenuControlTarget()
           MenuTargetConfiguration.ControlID = "InfoImageIcon"
           InfoContextMenu.Targets.Add(MenuTargetConfiguration)



I am getting a java script error with this code..

  1. Uncaught TypeError: Cannot read property 'target' of undefined Telerik.Web.UI.WebResource.axd:4660
    1. ShowInfoMenuOnLeftClickindex.aspx:560
    2. onmouseover

Can you help me!!

1 Answer, 1 is accepted

Sort by
0
Accepted
Boyan Dimitrov
Telerik team
answered on 07 Nov 2012, 12:59 PM
Hello Farid,

I prepared a sample project that demonstrates how you can find the RadContextMenu when is either created in code behind or in the markup. I would also recommend you take a look at this online demo that shows how a context menu pops up on image hover.

Hope that this will lead you into right direction.

Regards,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Menu
Asked by
shadow
Top achievements
Rank 2
Answers by
Boyan Dimitrov
Telerik team
Share this question
or