Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 27th, 2005, 04:13 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default open popup window in asp.net

I should create a link "Go to Page2" in page1.aspx and if user clicks it, it should open a popup window with page2.aspx (which pulls records from db). If I redirect from page1 to page2 it works but it I couldnt open as popup window from page1. I tried to use javascript (window.open with popup) but didnt work, got server error. could anybody please help me with complete code of this? i would really appreciate your help.

advance thanks.
 
Old December 27th, 2005, 10:20 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am absolutely sure some one else has a much better solution than what follows. What is below works for me. So please everyone excuse me if what follows is to convoluted, not the best solution etc. etc.

I have tried this and it works for me.

I included a javascript that opens up a pop up window:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">


The include file file looks like this:

<script language="javascript" type="text/javascript">
<!--

var win=null;

function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math .floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Mat h.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(scr een.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPositi on+',left='+LeftPosition+',scrollbars='+scroll+',l ocation=no,directories=no,status=no,menubar=no,too lbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}

// -->
</script>

I invoke my pop up window as follows:

<a href="Name of a aspx application.aspx" tabindex=-1 onclick="NewWindow(this.href,'Name of aspx','800','550','yes','center');return false" onfocus="this.blur()"> href display name </a>

Note: the quotes versus double quotes.

In reality I href to a scroll bar load page that then loads my application.



 
Old December 28th, 2005, 02:38 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default

will implement this solution. thanks for the quick response.
 
Old December 28th, 2005, 03:54 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

In order to launch a new window while doing a redirect requires a different approach. Instead of doing a redirect, you just need to emit the javascript that launches the new window (because a redirect will always happen in the same browser window).

-Peter
 
Old December 28th, 2005, 04:39 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am very sorry to disagree but my pop up window does just that it pops up with my apsx page
displayed in the pop up window. Perhaps you could try the code, I simply copied it from our
asp web site that has been in service for about 4 years.
Again I apologize, I admit I am new and not a guru, but it works.
Perhaps I am misunderstanding you. The java script takes in parameters to set the new size of the
pop up window: onclick="NewWindow(this.href,'Name of aspx','800','550','yes','center');

The 800, 550 is the new size of the window.

Perhaps if someone else has tried it they could confirm.

 
Old December 28th, 2005, 10:26 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Default

not a problem, thanks nutrino/planoie for all your input. with little help from my friend, i implemented the following solution and works great.

I added a lnkpg2 linkbutton "Open Page2" in page1.aspx:

in page load: lnkpg2.Attributes.Add("OnClick", "javascript:window.open('page2.aspx','Page2','widt h=500, height=500, menubar=no, scrollbars=yes, resizable=yes')")
 
Old August 2nd, 2006, 06:23 AM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Keep a "href" attribute in your link control. And also have an attribute "target=_blank". This will open in a new browser instance.

Hope this will be helpful.

Thanks,
MohanGandhi. C




Similar Threads
Thread Thread Starter Forum Replies Last Post
Popup Window using ASP.NET 2.0 Harjinder ASP.NET 2.0 Professional 3 January 31st, 2008 07:48 AM
open popup window with text reddyshekar C# 2005 1 July 2nd, 2007 08:34 AM
Popup window in Asp.net kotanaresh_2003 ASP.NET 1.0 and 1.1 Basics 3 April 12th, 2007 10:23 PM
ClientScript. : window.open -> Popup Blocker Issue AbrarNazeer ASP.NET 2.0 Professional 3 September 20th, 2006 09:59 AM
JavaScript : window.open -> Popup Blocker Issue AbrarNazeer Pro JSP 0 September 2nd, 2006 05:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.