Can menu items open new windows?

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
 
O

Onwuka Emeka

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:eek:penWin();" Target="_self"></asp:MenuItem>

</Items>

</asp:Menu>



<script language=javascript>

function openWin()

{

window.open('Default.aspx');

}

</script>



hope this helps
 
G

Guest

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:eek:penWin();" 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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top