473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Open in new window

I have an ASP.Net page that does a Response.Redirect to a code-created url.
Is there any way to code the redirect to open a new window similar to the
Javascript window.open() ? Thanks.

David
Sep 5 '07 #1
21 2340
no. it must be done via javascript or clicking an anchor (with a target).

-- bruce (sqlwork.com)

David C wrote:
I have an ASP.Net page that does a Response.Redirect to a code-created url.
Is there any way to code the redirect to open a new window similar to the
Javascript window.open() ? Thanks.

David

Sep 5 '07 #2
Along these lines:

I want to have a button that when clicked opens a new window and loads a
specific page. I tried many things, but none worked:

1 - Surround the button with a hyperlink control and no text with
thehyperlink.
2 - put in onclick=http://yada
3 - put in onclick="javascript:Window.Open(yada, '_blank');"
4 - in the Page_Load put in myButton.Attributes.Add("OnClick",
"Window.Open('yada', '_blank')")
....and probably some more attempts.

Nothing worked. Any ideas anyone?

Shelly

P.S. Why didn't they simply have attributes in the button control for the
navigation and the target specification? Yes, they have a space for an
image in the hyperlink control, but that means we would have to have the
image of a button when there is already a button design by default.
"bruce barker" <no****@nospam.comwrote in message
news:Oq**************@TK2MSFTNGP06.phx.gbl...
no. it must be done via javascript or clicking an anchor (with a target).

-- bruce (sqlwork.com)

David C wrote:
>I have an ASP.Net page that does a Response.Redirect to a code-created
url. Is there any way to code the redirect to open a new window similar
to the Javascript window.open() ? Thanks.

David

Sep 5 '07 #3
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
Nothing worked. Any ideas anyone?
<input type="button" value="New" onclick="window.open
('http://www.javascript-coder.com/window-popup/javascript-window-open.phtml','mywindow');"
/>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 5 '07 #4

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>Nothing worked. Any ideas anyone?

<input type="button" value="New" onclick="window.open
('http://www.javascript-coder.com/window-popup/javascript-window-open.phtml','mywindow');"
....and, oh yes, popups are enabled.
Sep 6 '07 #5

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>Nothing worked. Any ideas anyone?

<input type="button" value="New" onclick="window.open
('http://www.javascript-coder.com/window-popup/javascript-window-open.phtml','mywindow');"
I did this and nothing happened. What I put in was:

<input type="button" value="AA" onclick="window.open('thefile.aspx',
'Company List');" />

I also put in a complete url to a page that exists on the web rather than
'thefile,aspx' (which is in the same directory as the page I ran). Nothing
at all happened when I clicked on "AA".

Shelly
Sep 6 '07 #6
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:ul**************@TK2MSFTNGP05.phx.gbl...
>"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>>Nothing worked. Any ideas anyone?

<input type="button" value="New" onclick="window.open
('http://www.javascript-coder.com/window-popup/javascript-window-open.phtml','mywindow');"

...and, oh yes, popups are enabled.

Have you accidentally disabled JavaScript...?

Also, have you unchecked the browser option to display a warning for all
errors...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 6 '07 #7

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uN**************@TK2MSFTNGP05.phx.gbl...
>
Have you accidentally disabled JavaScript...?
No. Javascripts are enabled.
Also, have you unchecked the browser option to display a warning for all
errors...?
It is unchecked.

I verified these settings after your post and before I responded.

Shelly
Sep 6 '07 #8
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uN**************@TK2MSFTNGP05.phx.gbl...
>>
Have you accidentally disabled JavaScript...?

No. Javascripts are enabled.
>Also, have you unchecked the browser option to display a warning for all
errors...?

It is unchecked.

I verified these settings after your post and before I responded.

Hmm - starting to run out of ideas now...

When your page loads, do you see a warning symbol in the bottom left-hand
corner of your screen? If so, there's an error somewhere on the page...

When you do a View Source and find the window.open code, does it "look
right"...? Specifically, are there any carriage returns where you aren't
expecting them...?

Can you create a new page with nothing but the button in question on it -
does it work then...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 6 '07 #9
Solved! I need to add "javascript:" before the "window.open" command, and
have the full url there.

Now, the next thing is that I want to open a new page in the current window
and pass the info from one of the controls. Also, I want to do this with a
button. In php, I have the button submit, test on that, and then do a

header("Location: new_page_url?acct=" . $_POST['acctNumber']);

That sends the the info from the control "acctNumber" via the tag "acct",
and it opens that page in the current window. I want to do the same thing
here (in aspx), extracting the value from the control acctNumber so that it
is known in the next page. How do I do that? (Remember, I am just learning
this stuff)

Shelly
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:uN**************@TK2MSFTNGP05.phx.gbl...
>>>
Have you accidentally disabled JavaScript...?

No. Javascripts are enabled.
>>Also, have you unchecked the browser option to display a warning for all
errors...?

It is unchecked.

I verified these settings after your post and before I responded.


Hmm - starting to run out of ideas now...

When your page loads, do you see a warning symbol in the bottom left-hand
corner of your screen? If so, there's an error somewhere on the page...

When you do a View Source and find the window.open code, does it "look
right"...? Specifically, are there any carriage returns where you aren't
expecting them...?

Can you create a new page with nothing but the button in question on it -
does it work then...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 6 '07 #10
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>>Solved! I need to add "javascript:" before the "window.open" command,
and have the full url there.

Curious - that should only be required for pseudo-URLs i.e. making the
hyperlink run a bespoke JavaScript function...

????? I don't understand what you mean. I used:
onclick="javascript:window.open('the_page_url_incl uding_http');"
Yes, but you shouldn't have needed to use javascript: in front of
window.open...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 6 '07 #11
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
I guess I didn't mention it clearly enough about being in the same window.
OK, then, how do I get the value of a control from the caller page when I
am in the called page? As I have said, I have accomplished the navigation
(though I wish it weren't Javascript), but I need something to do what I
had done in php with $_GET.
OK - let's take a step back here...

Firstly, taking ASP.NET completely out of the equation for a second, there's
no requirement whatsoever to use JavaScript to move from one page to
another - that's what hyperlinks are for:
<a href='mysecondpage.aspx'>Second page</a>

Secondly, passing parameters from one page to the next can be easily
achieved via querystrings:
<a href='mysecondpage.aspx?ID=2'>Second page</a>

In the Page_Load of the second page:
int ID = Convert.ToInt32(Request.QueryString["ID"]);

Thirdly, in ASP.NET, if you want to persist data across pages, you have
several options:

1) You can still use the QueryString method

2) You can use postbacks and the Session object

3) In ASP.NET 2, you can do cross-page posting:
http://msdn2.microsoft.com/en-us/lib...39(vs.80).aspx

This is, essentially, submitting one page to another page...

Finally, the best advice I can give you is to completely forget about PHP -
none of it will be of any use to you in ASP.NET...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 7 '07 #12

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...

OK, Mark, I don't know where I am going wrong:

company.aspx:
<asp:Button ID="agents" runat="server" Text="Agents" OnClick="agents_Click"
/></asp:Button>

company.aspx.vb:
Sub agents_Click(ByVal sender As Object, ByVal e As Suystem.EventArgs)
Session["acct"] = acct.Text
Resume.Redirect(agents.aspx, false)
End Sub

agents.aspx.vb:
Sub Page_Load(ByVal sender As Object, ByVal e As Suystem.EventArgs)
accountNumber = Session["acct"].ToString()
Session.Remove["acct"]
End Sub
What I get is: BC30545: Property Access must assign to the property or use
its value
and it points to the Session["acct"] = acct.Text line. Note that there is a
control called acct in company.aspx

Shelly
Sep 7 '07 #13
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
OK, Mark, I don't know where I am going wrong:
accountNumber = Session["acct"].ToString()
accountNumber.Text = Session["acct"].ToString()

Assuming accountNumber is a TextBox control...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 7 '07 #14
Of couse the agents.aspx is inclosed in quotes (typo) in the redirect line.

I also tried commenting out the session variable statements and tried
"agents.aspx?acct=1106" and used the Request.QueryString("acct"). This
didn't give an exception (and took me to the page), but didn't set the
accountNumber.Text either.

Also, with the Redirect, the back button becomes disabled. Is this expected
?

Shelly
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...

OK, Mark, I don't know where I am going wrong:

company.aspx:
<asp:Button ID="agents" runat="server" Text="Agents"
OnClick="agents_Click" /></asp:Button>

company.aspx.vb:
Sub agents_Click(ByVal sender As Object, ByVal e As Suystem.EventArgs)
Session["acct"] = acct.Text
Resume.Redirect(agents.aspx, false)
End Sub

agents.aspx.vb:
Sub Page_Load(ByVal sender As Object, ByVal e As Suystem.EventArgs)
accountNumber = Session["acct"].ToString()
Session.Remove["acct"]
End Sub
What I get is: BC30545: Property Access must assign to the property or
use its value
and it points to the Session["acct"] = acct.Text line. Note that there is
a control called acct in company.aspx

Shelly

Sep 7 '07 #15

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>OK, Mark, I don't know where I am going wrong:
> accountNumber = Session["acct"].ToString()
accountNumber.Text = Session["acct"].ToString()

Assuming accountNumber is a TextBox control...
It is.

Shelly
Sep 7 '07 #16
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
Of couse the agents.aspx is inclosed in quotes (typo) in the redirect
line.
And it's Response.Redirect, not Resume.Redirect - missed that in my previous
reply...
I also tried commenting out the session variable statements and tried
"agents.aspx?acct=1106" and used the Request.QueryString("acct"). This
didn't give an exception (and took me to the page), but didn't set the
accountNumber.Text either.
Request.QueryString("acct").ToString()
Also, with the Redirect, the back button becomes disabled. Is this
expected ?
No..
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 7 '07 #17

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:ec**************@TK2MSFTNGP03.phx.gbl...
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>Of couse the agents.aspx is inclosed in quotes (typo) in the redirect
line.

And it's Response.Redirect, not Resume.Redirect - missed that in my
previous reply...
>I also tried commenting out the session variable statements and tried
"agents.aspx?acct=1106" and used the Request.QueryString("acct"). This
didn't give an exception (and took me to the page), but didn't set the
accountNumber.Text either.

Request.QueryString("acct").ToString()
>Also, with the Redirect, the back button becomes disabled. Is this
expected ?

No..
(A)
I fixed it to Response.QueryString("acct").ToString()
and Response.Redirect("agents.aspx?acct=1106", false)

It (1) goes to that page, (2) the back button is there, and (3) nothing
shows in accountNumber.Text

(B)
Also, using the other method, why couldn't I set a session variable. It
complained about that line. When I put in that line and started typing
session, it filled out the word "Session". But after I put in the rest
andgot to the acct.Text part, it didn't present me with acct (or anything,
for that matter) when I started typing it. If I start a line with ac it
presents me with the control acct, just not after the 'Session["acct"] ='
start of the line.

So, I still have two problems.
Sep 7 '07 #18
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
Also, using the other method, why couldn't I set a session variable. It
complained about that line. When I put in that line and started typing
session, it filled out the word "Session". But after I put in the rest
andgot to the acct.Text part, it didn't present me with acct (or anything,
for that matter) when I started typing it. If I start a line with ac it
presents me with the control acct, just not after the 'Session["acct"] ='
start of the line.

Apologies, I think that's my fault...

I never go anywhere near VB.NET, so I sometimes forget the syntatical
differences...

If, instead of Session["acct"] you try Session("acct") does it work...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 7 '07 #19

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Shelly" <sh************@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
>Also, using the other method, why couldn't I set a session variable. It
complained about that line. When I put in that line and started typing
session, it filled out the word "Session". But after I put in the rest
andgot to the acct.Text part, it didn't present me with acct (or
anything, for that matter) when I started typing it. If I start a line
with ac it presents me with the control acct, just not after the
'Session["acct"] =' start of the line.


Apologies, I think that's my fault...
Man, he is human after all :-) I'll match your one against my [at least]
100.
>
I never go anywhere near VB.NET, so I sometimes forget the syntatical
differences...
I would have used C#, except that most of the jobs here seem to say VB.Net.
So, I went that way. (I tell you it is a bitch to go back and forth between
a sentence delimited language (C#, PHP, C, Java, etc.) and a card image [aka
lines] one (VB, Fortran, Basic). I always seem to leave of the ";" when I
flip back :-) )
>
If, instead of Session["acct"] you try Session("acct") does it work...?
Well, it didn't produce any errors, but it didn't get the value either.

In company.aspx.vb I have in the agents_Click subroutine:
Session("acct") = acct.Text
Response.Redirect("agents.aspx", False)

and in the agents.aspx.vb Page_load I have:
accountNumber.Text = Session("acct").ToString()
Session.Remove("acct")

and, yes, there is a TextBox control "acct" in company.aspx and there is a
TextBox control accountNumber in agents.aspx.

So, now there are two things that give the next page, but neither way gives
me either session variable or the passed variable.

Shelly
Sep 7 '07 #20
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
....

Mark, I figured it out. I went into the debugger and found that the
Page_Load routine in the target page was not firing. I figured out why. It
is because I did not have "Handles Me.Load" at the end of the subroutine
declaration.

In the process of the investigation, I also came across where I could read
the value of the previous page's control from within the target page. I
bookmarked that page for later study.

Thanks for all the help.

Shelly
Sep 9 '07 #21
"Sheldon Glickler" <sh*******@asap-consult.comwrote in message
news:13*************@corp.supernews.com...
Mark, I figured it out. I went into the debugger and found that the
Page_Load routine in the target page was not firing. I figured out why.
It is because I did not have "Handles Me.Load" at the end of the
subroutine declaration.
Ah... yet another reason to ditch VB.NET immediately and move to C#... ;-)
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Sep 9 '07 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page...
6
by: Les | last post by:
Hi, I'd like to find out how to use the window.open() script in Fireworks MX. I have posted my question in the Fireworks forum but didn't get any replies. Since it's javascript, maybe someone...
10
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#"...
10
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a...
2
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
2
by: Larry R Harrison Jr | last post by:
I have pull-down menus in javascript and I have the code for opening a link in a new window. But I want it to open a full-sized window. I can't figure out the syntax. What I have so far: ...
8
by: Dominic Tocci | last post by:
I'm searching for a way to use window.open on my web page to open a window in firefox that allows the sidebars to work (bookmarks, history, etc). When I use the following: var...
7
by: anthony.turcotte | last post by:
Hi, I've looked for a solution to this problem on google, read posts in this newsgroup and I still haven't found anything that could help me. Here's the scenario. 1. User accesses...
13
by: Geoff Fox | last post by:
I am in the final moments of designing a new website. One of the pages (http://www.auditionfactory.com/samples.php) has four links to show sample work. I would like these links to open new...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.