Click here to Skip to main content
15,891,855 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I need help for my code.

I am having Menubars and MenuItems which are LinkButtons. As per requirement I need to open links(MenuItems) in new tab as well as on new windows when user RightClicks on the MenuItems and selects either "open in New Tab" or "open in New Window"

Problem is : When I select any MenuItem and click on any of these open in new tab or open in new window ; it opens in the same page rather than opening in new tab or window.

XML
<li class="firstNav" ><a href="#" id ="regmenu">Register</a>
                         <ul class ="sub">
                            <li>
                                <asp:LinkButton ID ="lnkRegisterInvoice" runat ="server" Text ="Invoice" OnClick ="lnkRegisterInvoice_Click"></asp:LinkButton>
                            </li>
                            <li>
                                <asp:LinkButton ID ="lnkRegisterACInvoice" runat ="server" Text ="Article Charge Invoice" OnClick ="lnkRegisterACInvoice_Click"></asp:LinkButton>
                            </li>
                             <li>
                                <asp:LinkButton ID ="lnkRegisterCreditNote" runat ="server" Text ="Credit Note" OnClick ="lnkRegisterCreditNote_Click"></asp:LinkButton>
                            </li>
                            <li>
                                <asp:LinkButton ID ="lnkRegisterACCreditNote" runat ="server" Text ="Article Charge Credit Note" OnClick ="lnkRegisterACCreditNote_Click"></asp:LinkButton>
                            </li>
                         </ul>
                         </li>



Any suggestion is appreciated :)
Posted
Updated 1-Feb-12 0:33am
v2

Hii Guys,

Got the solution, Instead of LinkButton now I took asp:HyperLink use NavigateUrl="requiredpage.aspx" and target="_self"

Also need to make javascript function (for calling server side button click event)and call them on page_load event,and make your button click event.

Thanks Christian Graus and Kreagan Naicker,Thanks for your help and precious time. :)
 
Share this answer
 
v2
Comments
Tech Code Freak 2-Feb-12 5:37am    
Got the answer...then just accept your Solution!
Always great solving yourself!
5up!
manognya kota 2-Feb-12 6:54am    
Good luck! my 5
Arpit_Soni 2-Feb-12 7:15am    
Thanks Guys.... hi5..n Good Luck to all.
Member 10504170 26-Mar-14 10:06am    
okk
nithinc47 17-May-14 15:59pm    
Its working Arpit_Soni ur superb
You can't change how the browser works or it's definition of a 'new window'. How many browsers have you tested this on ? Using Chrome, that link works fine for me on this web page. Does it work fine for you ? If so, then I guess some HTML is required, but I see nothing fancy in the HTML of the links I tested on.
 
Share this answer
 
Hi Arpit_Soni.

You can try:

ASP.NET
<asp:linkbutton id="lnkRegisterInvoice" runat="server" text="Invoice" onclick="window.open('registerinvoice.aspx');return false;" ></asp:linkbutton>


If the above doesn't meet your requirement you could always try the following:

HTML
<a href="RegisterInvoice.aspx" target="_blank">Invoice</a>
 
Share this answer
 
v2
Comments
Christian Graus 1-Feb-12 14:19pm    
These will open in a new window no matter what, that's not what he wants.
Arpit_Soni 2-Feb-12 1:20am    
Hi Christian Graus/Kreagan Naicker, @Christian: I have checked on IE7 and on Mozilla.On Mozilla it even don't display "open in New Tab" or "open in New Window". But if I use "a href"the issue is resolved, but I can't use "a href" since I am having OnClick events on the LinkButton. @ Kreagan Naicker:I am already having OnClick ="lnkRegisterInvoice_Click" event," a href" is working fine I have tested it before also, but we are having LinkButtons. Also, window.open() always opens in new tab.
Tech Code Freak 2-Feb-12 5:38am    
Edited to remove xmlns:.....
Changed "..." to '...'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900