Solved

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

Posted on 2011-02-17
9
972 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 53

Accepted Solution

by:
Huseyin KAHRAMAN earned 500 total points
ID: 34923405
simple:

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

Expert Comment

by:Huseyin KAHRAMAN
ID: 34923414
this may work too

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

Expert Comment

by:Huseyin KAHRAMAN
ID: 34923419
or

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

vb code:
hlPrintCart.attributes.add("onClick","ShowWindow()");
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 53

Expert Comment

by:Huseyin KAHRAMAN
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 53

Expert Comment

by:Huseyin KAHRAMAN
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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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 the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

734 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