Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 27th, 2005, 03: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.
Reply With Quote
  #2 (permalink)  
Old December 27th, 2005, 09: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.



Reply With Quote
  #3 (permalink)  
Old December 28th, 2005, 01: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.
Reply With Quote
  #4 (permalink)  
Old December 28th, 2005, 02: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,413
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
Reply With Quote
  #5 (permalink)  
Old December 28th, 2005, 03: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.

Reply With Quote
  #6 (permalink)  
Old December 28th, 2005, 09: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')")
Reply With Quote
  #7 (permalink)  
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 06: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



All times are GMT -4. The time now is 05:59 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.