Solved

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

Posted on 2011-02-17
9
970 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
9 Comments
 
LVL 51

Accepted Solution

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

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

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 51

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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 51

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 51

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

828 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