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

Javascript on Context Menu Click

2 Answers 104 Views
Menu
This is a migrated thread and some comments may be shown as answers.
TPerry
Top achievements
Rank 1
TPerry asked on 10 Feb 2009, 08:09 PM
I have a RadGrid with a ContextMenu appearing when you right click.  When you click on an item in the context menu, I want to open a new window using Javascript.  I get into the ItemClick sub on the menu, but my Javascript is not firing.  I'm certain that I have something wrong in the RegisterStartupScript line.  I even think it's my first parameter.  What should go there?  The grid is ajaxed, so there's no postback, I tried the name of the menu as well.  Help?

Dim

 

strScript As String = ""

 

strScript =

"<script type='text/javascript'>window.open('http://www.google.com'); </script>"

 

ScriptManager.RegisterStartupScript(GridFees,

Me.GetType(), "myKey", strScript, True)

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 Feb 2009, 09:55 AM
Hi,

Try the following code snippet and check whether it's working for you.

CS:
Protected Sub RadContextMenu1_ItemClick(ByVal sender As ObjectByVal e As RadMenuEventArgs)  
     If e.Item.Text = "OpenWindow" Then 
         Dim strScript As String = "<script type='text/javascript'>" 
         strScript += "window.open('http://www.google.com');" 
         strScript += "</script>" 
         ScriptManager.RegisterStartupScript(Me.Page, Me.[GetType](), "myKey", strScript, False)  
     End If 
End Sub 

Thanks,
Princy.
0
TPerry
Top achievements
Rank 1
answered on 12 Feb 2009, 03:09 PM
That was it!  Thank you so much!
Tags
Menu
Asked by
TPerry
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
TPerry
Top achievements
Rank 1
Share this question
or