Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Opening the navigate url in a new browser instead of redirecting in the same browser

Posted on 2011-02-17
9
Medium Priority
?
985 Views
Last Modified: 2012-05-11
I have asp:hyperlink in my webpage. Onclick I would like to open this in a new window instead of redirecting in the same browser.
Basically I would like to have the same effect as having an input button and on click calling the attached javascript function showwindow(). Please suggest how can I call this javascript function from the click of the asp:hyperlink. should I rather use any other html control . Please help thanks

<asp:HyperLink ID="hlPrintCart" NavigateUrl="/showwindow.aspx" runat="server">Print page</asp:HyperLink>      
function ShowWindow()
                        {
                        var h = 500;
                        var w = 600;        
                        PackingSlipPopUp = window.open("showwindow.aspx","_blank","scrollbars=yes,toolbar=yes,resizable=yes,location=no,status=no,width=" + w + ",height=" + h + ",top= " + ((screen.height - h) / 5) + ",left=" + ((screen.width - w) / 2));
                        PackingSlipPopUp.focus();
                        }
0
Comment
Question by:TrialUser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 60

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 34923405
simple:

NavigateUrl="javascript:ShowWindow()"
0
 
LVL 60

Expert Comment

by:HainKurt
ID: 34923414
this may work too

<asp:HyperLink ID="hlPrintCart" NavigateUrl="#" onClick="ShowWindow()" runat="server">Print page</asp:HyperLink>
0
 
LVL 60

Expert Comment

by:HainKurt
ID: 34923419
or

<asp:HyperLink ID="hlPrintCart" NavigateUrl="#" runat="server">Print page</asp:HyperLink>

vb code:
hlPrintCart.attributes.add("onClick","ShowWindow()");
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 60

Expert Comment

by:HainKurt
ID: 34923424
or, why do you need server control for this? use simple <a> element

<a href="#" onClick="ShowWindow()">Print page</a>
0
 
LVL 8

Expert Comment

by:Anurag Agarwal
ID: 34923679
hello TrialUser !! instaed of using everything just use this ......

<asp:HyperLink ID="hlPrintCart" NavigateUrl="/showwindow.aspx" runat="server" Target="_blank">Print page</asp:HyperLink>  

for reference look http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink.target.aspx
0
 
LVL 8

Expert Comment

by:Anurag Agarwal
ID: 34923685
no javascripts will be required in this case .............!!
0
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 34924546
Hi, you have to use


target="_blank"
0
 
LVL 60

Expert Comment

by:HainKurt
ID: 34926673
target="_blank" is not he wants I guess:

if you look at this code

window.open("showwindow.aspx","_blank","scrollbars=yes,toolbar=yes,resizable=yes,location=no,status=no,width=" + w + ",height=" + h + ",top= " + ((screen.height - h) / 5) + ",left=" + ((screen.width - w) / 2));

he wants to open it in a NICE window, not in a new window :) this is what I get... and thats why he has that open function...
0
 

Author Closing Comment

by:TrialUser
ID: 34928117
perfect thx
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question