Can menu items open new windows?

  • Thread starter Thread starter ceolino
  • Start date Start date
C

ceolino

Hi all,
how can I use menu object to open a new window instead of postback to
the same page where the menu is? What I'd like to do is like invoking
"window.open()" (javascript) from a menu item.

Thanks in advance
 
You can do that by setting the NavigateUrl property to a javascript function
that opens the new window
<asp:Menu ID="Menu1" runat="server">

<Items>

<asp:MenuItem Text="Javascript Menu" Value="Javascript Menu"
NavigateUrl="javascript:openWin();" Target="_self"></asp:MenuItem>

</Items>

</asp:Menu>



<script language=javascript>

function openWin()

{

window.open('Default.aspx');

}

</script>



hope this helps
 
Onwuka Emeka said:
You can do that by setting the NavigateUrl property to a javascript function
that opens the new window
<asp:Menu ID="Menu1" runat="server">
<Items>
<asp:MenuItem Text="Javascript Menu" Value="Javascript Menu"
NavigateUrl="javascript:openWin();" Target="_self"></asp:MenuItem>
</Items>
</asp:Menu>

Can you not just set the target to _blank?

<asp:MenuItem Text="Test Menu" Value="Test Menu"
NavigateUrl="SomePage.aspx" Target="_blank"></asp:MenuItem>
 
Back
Top