Dynamically building menu items and need to call a javascript function from one of them.
function popWin(url) {
var winHandle= window.open(url, '_blank', 'width=1000,height=700,resizable=yes,top=5,left=5,scrollbars=yes,status=yes');
}
<asp:Menu ID="Menu1" runat="server" StaticDisplayLevels="8" RenderingMode="List" OnMenuItemClick="Menu1_MenuItemClick" CssClass="menu" Width="150px">
</asp:Menu>
The code behind:
string url ="/somepage.aspx";
MenuItem child= new MenuItem();
child.Text ="Some Text";
child.NavigateUrl = "javascript:popWin('" + url + "');";
//child.NavigateUrl ="javascript:window.open('somepage.aspx');";
Menu1.Items[1].ChildItems.Add(child);
Just having some trouble calling the javascript function.
The window.open will work but an extra page opens and I need more control over the window opening.
The reason this needs to be done this way is there's an iFrame on the page that's loading different pages. The RegisterStartupScript was being used in the Menu1_MenuItemClick event but it was refreshing the source of the iFrame.
Thanks for any suggestions.
Anonymous User
24-Mar-2015After coming back to this problem and testing a span tag in html with an onclick event, the problem was simply a bit of syntax:
Thought I would post this just in case anyone else runs into the same issue.