Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

form1.target='_blank';

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonathan Wood - 20 Feb 2008 00:16 GMT
I tried adding the subject of this post in my button's OnClientClick
property. But the result goes to the same window.

Does anyone know how to have a button (and only one button) on a form post
to itself in a new window?

And, if not, does anyone know how to cross post to another URL in a new
window?

Thanks.

Signature

Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Mark Rae [MVP] - 20 Feb 2008 00:34 GMT
> And, if not, does anyone know how to cross post to another URL in a new
> window?

http://www.google.co.uk/search?sourceid=navclient&aq=t&hl=en-GB&ie=UTF-8&rlz=1T4
GZEZ_en-GBGB252GB252&q=JavaScript+%22window%2eopen%22


Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Jonathan Wood - 20 Feb 2008 02:33 GMT
As far as I know, window.open does a GET, and not a POST. Am I missing
something?

Signature

Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

>> And, if not, does anyone know how to cross post to another URL in a new
>> window?
>
> http://www.google.co.uk/search?sourceid=navclient&aq=t&hl=en-GB&ie=UTF-8&rlz=1T4
GZEZ_en-GBGB252GB252&q=JavaScript+%22window%2eopen%22
Mark Rae [MVP] - 20 Feb 2008 02:41 GMT
[top-posting corrected]

>>> And, if not, does anyone know how to cross post to another URL in a new
>>> window?
[quoted text clipped - 3 lines]
> As far as I know, window.open does a GET, and not a POST. Am I missing
> something?

Yes. If you want to open a new window, you have no other choice as that
action can only be performed client-side...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Jonathan Wood - 20 Feb 2008 02:51 GMT
I understand it can only be accomplished client side. However, I know that
the form tag can include a TARGET="_blank" attribute and, AFAIK, that works.
So it can be accomplished. The only thing is how to make it only that way
for one button.

So I still don't see what I'm missing.

Signature

Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

> [top-posting corrected]
>
[quoted text clipped - 8 lines]
> Yes. If you want to open a new window, you have no other choice as that
> action can only be performed client-side...
Scott Roberts - 20 Feb 2008 05:30 GMT
Not sure about using target="_blank", but something I've done in the past is
go ahead and let the button post back as usual then add a startup script in
the button event handler (using RegisterClientStartupScript) to open a new
window using javascript. To pass the processed data, you can put it in an
object (or struct) and stuff it into the session, then read that session
variable from the page opened in the new window.

Just an idea. It may or may not work for your situation.

>I understand it can only be accomplished client side. However, I know that
>the form tag can include a TARGET="_blank" attribute and, AFAIK, that
[quoted text clipped - 15 lines]
>> Yes. If you want to open a new window, you have no other choice as that
>> action can only be performed client-side...
Jonathan Wood - 20 Feb 2008 17:34 GMT
Hi Scott,

> Not sure about using target="_blank", but something I've done in the past
> is go ahead and let the button post back as usual then add a startup
[quoted text clipped - 4 lines]
>
> Just an idea. It may or may not work for your situation.

Certainly more overhead than is ideal, but I suppose that would work. I'll
need to think through that a bit.

Thanks.

Signature

Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

lemieux.raphael@csob.qc.ca - 04 Mar 2008 19:23 GMT
Hi,

  I did manage to do what you needed by addin the following line of
code to the OnClientClick of a linkbutton :

javascript:var aspnettarget;
aspnettarget=document.forms[0].target;document.forms[0].target='_blank';eval(this.href);document.forms[0].target=aspnettarget;
return false;

 I guess you understand what it does, but for others who might
wonder,

aspnettarget=document.forms[0].target;         keeps the default
Target of the normal ASP.NET Form
document.forms[0].target='_blank';                Changes the actual
target of the form to _Blank so it opens in a new window
eval(this.href);                                              does a
normal postback of the button to the new target
document.forms[0].target=aspnettarget;         Sets back the normal
Target for the ASP.Net Form
return false;                                                 Cancel
the "normal" call to the __Postback method since we already called it.

 It worked for me just as needed... Hope this helps.

Raphaël LEMIEUX
lemieux.raphael@csob.qc.ca - 04 Mar 2008 19:29 GMT
Hi,

  I did manage to do what you needed by addin the following line of
code to the OnClientClick of a linkbutton :

javascript:var aspnettarget;
aspnettarget=document.forms[0].target;document.forms[0].target='_blank';eva­
l(this.href);document.forms[0].target=aspnettarget;
return false;

 I guess you understand what it does, but for others who might
wonder,

aspnettarget=document.forms[0].target;         keeps the default
Target of the normal ASP.NET Form
document.forms[0].target='_blank';                Changes the actual
target of the form to _Blank so it opens in a new window
eval(this.href);                                              does a
normal postback of the button to the new target
document.forms[0].target=aspnettarget;         Sets back the normal
Target for the ASP.Net Form
return false;                                                 Cancel
the "normal" call to the __Postback method since we already called
it.

 It worked for me just as needed... Hope this helps.

Raphaël LEMIEUX

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.