Click here to Skip to main content
15,881,881 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello greetings!!!

I want to open a link in new tab i used link button and also set target as blank.
XML
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="window.document.forms[0].target='_blank';"                                                                                                    PostBackUrl="[Same Page with the appication]" style="color:White;font-family: MyriadPro,Arial, Helvetica, sans-serif;text-decoration:underline; font-size: large;  font-weight: bold;padding-left:30px;" Text="View ">

After doing this.
the link on previous tab won't work.

Thank You!
Posted
v4
Comments
Maarten Kools 9-Aug-13 8:31am    
What link on the previous tab? The same link? Have you looked for any (JavaScript) errors?
Thanks7872 9-Aug-13 8:33am    
Posting the code would make two things better
1) For us to help you.
2) For you to get quick resolution.
JasonMacD 9-Aug-13 8:46am    
You have used the correct approach:

<asp:Button ........OnClientClick="NameofForm.target ='_blank';"/>

You may need to only use the form actual name and not the index of.
Maarten Kools 9-Aug-13 8:56am    
My first idea is, why do a postback to a new window? That doesn't sound like a good idea, as the previous page does not update its viewstate and such. Haven't tested myself if that's the problem, but I can imagine it might be.
Dholakiya Ankit 25-Sep-13 3:29am    
One more thing with this if you aspect answer fastly you have to reply as quick as possible :)

You can Use java script code

XML
<script language="javascript" type="text/javascript">
    function Al()
    {
        window.open("http://mpcongress.org");
        window.focus();

    }


set the href location to " ", that is blank, use onclick event to call function Al()

HTML
<ul><li><a href=" "  önclick="Al()"> link </a></li></ul>
 
Share this answer
 
v2
You could use a
HTML
asp:Hyperlink
instead of
HTML
asp:LinkButton

ASP.NET
<asp:hyperlink id="HyperLink1" runat="server" target="_blank" navigateurl="[Same Page with the appication]" style="color:White;font-family: MyriadPro,Arial, Helvetica, sans-serif;text-decoration:underline; font-size: large;  font-weight: bold;padding-left:30px;" text="View" xmlns:asp="#unknown"></asp:hyperlink>
 
Share this answer
 

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