473,396 Members | 1,813 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,396 software developers and data experts.

Redirect and Target="_blank"

I want to redirect the user to a url outside of our website but I want it to
preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external sites.
The hyperlink columns have the target="_blank" attribute so they preserve
the existing window. This works OK except that the NavigateURL's are quite
long due to the size of the query string and this makes the page slow. What
I've done is I've changed the hyperlink columns to template columns with a
linkbutton control. Now when a link is clicked I form the URL with the long
querystring (using the command argument and other values from some dropdown
list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's,
but the external links on the page do not open in a new window as before.
Is there a method I can use that will duplicate the Target="_blank" behavior
and preserve our application window?

Thanks,
Al
Nov 18 '05 #1
8 3841

Maybe there is a better solution but anyway:

Create a JavaScript on the Serverside (in your Code)
and send it back to the Client where it the is executed.

It seams that you do a serverroundtrip anyway with your solution.
Instead of:
Response.Redirect(url, False)
write:

Response.write "<script language='JavaScript'>" & vbcrlf
Response.write "<!--" & vbcrlf
Response.write "window.open( )" & vbcrlf
Response.write "//-->" & vbcrlf
Response.write "</script>" & vbcrlf
But I think if you looking to design a fast site the solution with the
serverroundtrips isn't very fast.

Maybe you can make the long expression shorter.
May be there are parts in the URL that are always the same.
So take this parts into JavaScript Variables and put
the real URL then at runtime.

Cherrio
"msnews.microsoft.com" <ca*****@hotmail.com> schrieb im Newsbeitrag
news:uF**************@TK2MSFTNGP10.phx.gbl... I want to redirect the user to a url outside of our website but I want it to preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external sites. The hyperlink columns have the target="_blank" attribute so they preserve
the existing window. This works OK except that the NavigateURL's are quite long due to the size of the query string and this makes the page slow. What I've done is I've changed the hyperlink columns to template columns with a
linkbutton control. Now when a link is clicked I form the URL with the long querystring (using the command argument and other values from some dropdown list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's,
but the external links on the page do not open in a new window as before.
Is there a method I can use that will duplicate the Target="_blank" behavior and preserve our application window?

Thanks,
Al

Nov 18 '05 #2
you can do it by using Item_databound in grid control that
find the linkbutton and add an attributelike

myLinkButton.Attributes.Add("Target", "_blank")

regards
Ather Ali Shaikh

"msnews.microsoft.com" <ca*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
I want to redirect the user to a url outside of our website but I want it to preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external sites. The hyperlink columns have the target="_blank" attribute so they preserve
the existing window. This works OK except that the NavigateURL's are quite long due to the size of the query string and this makes the page slow. What I've done is I've changed the hyperlink columns to template columns with a
linkbutton control. Now when a link is clicked I form the URL with the long querystring (using the command argument and other values from some dropdown list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's,
but the external links on the page do not open in a new window as before.
Is there a method I can use that will duplicate the Target="_blank" behavior and preserve our application window?

Thanks,
Al

Nov 18 '05 #3
You must have a monster of a page if a bunch of URLs are slowing it down! In
any case, if you want to keep the URLs out of the page, first you have to
understand first that there are only 2 ways to launch a new instance of your
browser: (1) using target frame, and (2) using the JavaScript window.open()
method. Obviously, the target frame solution doesn't work, as it requires
the URL to be in the page at the time the link is clicked. So, if I
understand you correctly, your requirement is that the URLs are not in the
Page, but that an event such as a click must open in a new Window with a
dynamically-generated URL, your path is pretty-well set.

First, in order to do any navigation, you will need a URL. Since your
requirement is that no URLs appear in the page, this means that you have to
do a PostBack to fetch the appropriate one. You can choose whatever type of
Control you desire into your DataGrid to initiate the PostBack; the
important thing is that you write a server-side event handler for the click
event of that Control. The server-side event handler would then fetch the
URL for that Control, and use Page.RegisterStartupScript to add a JavaScript
to the Page which runs when the Page reloads. That JavaScript would use the
window.open() method to open the URL in a new browser instance.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"msnews.microsoft.com" <ca*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
I want to redirect the user to a url outside of our website but I want it to preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external sites. The hyperlink columns have the target="_blank" attribute so they preserve
the existing window. This works OK except that the NavigateURL's are quite long due to the size of the query string and this makes the page slow. What I've done is I've changed the hyperlink columns to template columns with a
linkbutton control. Now when a link is clicked I form the URL with the long querystring (using the command argument and other values from some dropdown list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's,
but the external links on the page do not open in a new window as before.
Is there a method I can use that will duplicate the Target="_blank" behavior and preserve our application window?

Thanks,
Al

Nov 18 '05 #4
Dear Captain Chaos,

Thanks for your suggestions. I'm going to try your solution.

Al
"Captain Chaos" <no****@nospam.com> wrote in message
news:bs*************@news.t-online.com...

Maybe there is a better solution but anyway:

Create a JavaScript on the Serverside (in your Code)
and send it back to the Client where it the is executed.

It seams that you do a serverroundtrip anyway with your solution.
Instead of:
Response.Redirect(url, False)
write:

Response.write "<script language='JavaScript'>" & vbcrlf
Response.write "<!--" & vbcrlf
Response.write "window.open( )" & vbcrlf
Response.write "//-->" & vbcrlf
Response.write "</script>" & vbcrlf
But I think if you looking to design a fast site the solution with the
serverroundtrips isn't very fast.

Maybe you can make the long expression shorter.
May be there are parts in the URL that are always the same.
So take this parts into JavaScript Variables and put
the real URL then at runtime.

Cherrio
"msnews.microsoft.com" <ca*****@hotmail.com> schrieb im Newsbeitrag
news:uF**************@TK2MSFTNGP10.phx.gbl...
I want to redirect the user to a url outside of our website but I want it to
preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external

sites.
The hyperlink columns have the target="_blank" attribute so they

preserve the existing window. This works OK except that the NavigateURL's are

quite
long due to the size of the query string and this makes the page slow.

What
I've done is I've changed the hyperlink columns to template columns with a linkbutton control. Now when a link is clicked I form the URL with the

long
querystring (using the command argument and other values from some

dropdown
list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's, but the external links on the page do not open in a new window as before. Is there a method I can use that will duplicate the Target="_blank"

behavior
and preserve our application window?

Thanks,
Al


Nov 18 '05 #5
I'll try it. Thanks.

"Ather Ali Shaikh" <at*******@eintelligencesoft.com> wrote in message
news:uR**************@TK2MSFTNGP12.phx.gbl...
you can do it by using Item_databound in grid control that
find the linkbutton and add an attributelike

myLinkButton.Attributes.Add("Target", "_blank")

regards
Ather Ali Shaikh

"msnews.microsoft.com" <ca*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
I want to redirect the user to a url outside of our website but I want it
to
preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external

sites.
The hyperlink columns have the target="_blank" attribute so they

preserve the existing window. This works OK except that the NavigateURL's are

quite
long due to the size of the query string and this makes the page slow.

What
I've done is I've changed the hyperlink columns to template columns with a linkbutton control. Now when a link is clicked I form the URL with the

long
querystring (using the command argument and other values from some

dropdown
list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's, but the external links on the page do not open in a new window as before. Is there a method I can use that will duplicate the Target="_blank"

behavior
and preserve our application window?

Thanks,
Al


Nov 18 '05 #6
Yes, it is a monster. When I remove the hyperlinks, it's much much faster.
I think you grasped the problem correctly. Thanks for your detailed
explanation. I'm going to try your solution. I did not know about the
Page.RegisterStartupScript method.

Thanks,
Al

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You must have a monster of a page if a bunch of URLs are slowing it down! In any case, if you want to keep the URLs out of the page, first you have to
understand first that there are only 2 ways to launch a new instance of your browser: (1) using target frame, and (2) using the JavaScript window.open() method. Obviously, the target frame solution doesn't work, as it requires
the URL to be in the page at the time the link is clicked. So, if I
understand you correctly, your requirement is that the URLs are not in the
Page, but that an event such as a click must open in a new Window with a
dynamically-generated URL, your path is pretty-well set.

First, in order to do any navigation, you will need a URL. Since your
requirement is that no URLs appear in the page, this means that you have to do a PostBack to fetch the appropriate one. You can choose whatever type of Control you desire into your DataGrid to initiate the PostBack; the
important thing is that you write a server-side event handler for the click event of that Control. The server-side event handler would then fetch the
URL for that Control, and use Page.RegisterStartupScript to add a JavaScript to the Page which runs when the Page reloads. That JavaScript would use the window.open() method to open the URL in a new browser instance.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"msnews.microsoft.com" <ca*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
I want to redirect the user to a url outside of our website but I want it
to
preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external

sites.
The hyperlink columns have the target="_blank" attribute so they

preserve the existing window. This works OK except that the NavigateURL's are

quite
long due to the size of the query string and this makes the page slow.

What
I've done is I've changed the hyperlink columns to template columns with a linkbutton control. Now when a link is clicked I form the URL with the

long
querystring (using the command argument and other values from some

dropdown
list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's, but the external links on the page do not open in a new window as before. Is there a method I can use that will duplicate the Target="_blank"

behavior
and preserve our application window?

Thanks,
Al


Nov 18 '05 #7
Kevin,

Would the window.open() be inside of a function in the JavaScript?

Or could it be like this:

' Form the script to be registered at client side.
Dim scriptString As String = "<script language=JavaScript>
window.open(); "
scriptString += "<"
scriptString += "/"
scriptString += "script>"

If (Not Me.IsStartupScriptRegistered("Startup")) Then
Me.RegisterStartupScript("Startup", scriptString)
End If

I put the above code in the event handler of the linkButton Command event.
It didn't have any effect. I stepped through it so I know that it is
executing.

Thanks,
Al
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You must have a monster of a page if a bunch of URLs are slowing it down! In any case, if you want to keep the URLs out of the page, first you have to
understand first that there are only 2 ways to launch a new instance of your browser: (1) using target frame, and (2) using the JavaScript window.open() method. Obviously, the target frame solution doesn't work, as it requires
the URL to be in the page at the time the link is clicked. So, if I
understand you correctly, your requirement is that the URLs are not in the
Page, but that an event such as a click must open in a new Window with a
dynamically-generated URL, your path is pretty-well set.

First, in order to do any navigation, you will need a URL. Since your
requirement is that no URLs appear in the page, this means that you have to do a PostBack to fetch the appropriate one. You can choose whatever type of Control you desire into your DataGrid to initiate the PostBack; the
important thing is that you write a server-side event handler for the click event of that Control. The server-side event handler would then fetch the
URL for that Control, and use Page.RegisterStartupScript to add a JavaScript to the Page which runs when the Page reloads. That JavaScript would use the window.open() method to open the URL in a new browser instance.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"msnews.microsoft.com" <ca*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
I want to redirect the user to a url outside of our website but I want it
to
preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external

sites.
The hyperlink columns have the target="_blank" attribute so they

preserve the existing window. This works OK except that the NavigateURL's are

quite
long due to the size of the query string and this makes the page slow.

What
I've done is I've changed the hyperlink columns to template columns with a linkbutton control. Now when a link is clicked I form the URL with the

long
querystring (using the command argument and other values from some

dropdown
list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's, but the external links on the page do not open in a new window as before. Is there a method I can use that will duplicate the Target="_blank"

behavior
and preserve our application window?

Thanks,
Al


Nov 18 '05 #8
Ather Ali Shaikh,

I added the attribute but it doesn't seem to have had any effect.

Al
"Ather Ali Shaikh" <at*******@eintelligencesoft.com> wrote in message
news:uR**************@TK2MSFTNGP12.phx.gbl...
you can do it by using Item_databound in grid control that
find the linkbutton and add an attributelike

myLinkButton.Attributes.Add("Target", "_blank")

regards
Ather Ali Shaikh

"msnews.microsoft.com" <ca*****@hotmail.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
I want to redirect the user to a url outside of our website but I want it
to
preserve our application's window by opening a new window. We have a
datagrid that has five hyperlink columns containing links to external

sites.
The hyperlink columns have the target="_blank" attribute so they

preserve the existing window. This works OK except that the NavigateURL's are

quite
long due to the size of the query string and this makes the page slow.

What
I've done is I've changed the hyperlink columns to template columns with a linkbutton control. Now when a link is clicked I form the URL with the

long
querystring (using the command argument and other values from some

dropdown
list controls) and do a redirect to that URL:

Response.Redirect(url, False)

This makes the page much faster because it does not have those long URL's, but the external links on the page do not open in a new window as before. Is there a method I can use that will duplicate the Target="_blank"

behavior
and preserve our application window?

Thanks,
Al


Nov 18 '05 #9

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

Similar topics

9
by: Sugapablo | last post by:
I admit, I'm terrible creating reg ex's. I'm trying to create a preg_replace that would remove from a <a href> tag that would replace the target attribute regardless of what the value might be....
12
by: Romain | last post by:
Hi, I've used an excellent way to make target="_blank" links that still validate while using HTML 4.01 Transitional doctypes in the past. I learned the trick from :...
1
by: Nick Messick | last post by:
I'm going through some old code and have found this a number of places. Seems kind of strange. Is there any reason why someone would do this?
16
by: St. Rechsteiner | last post by:
Hi How i made the same effect in xHTML like the - target="_blank" - Tag in HTML 4.01? I will use it with xHTML and CSS ... but the validator say's to me, that this tag wasn't valid for xHTML!...
6
by: Tony Marston | last post by:
The code <a href="..." target="_blank">...</a> will not validate as XHTML STRICT because of the 'target' tag, so how do I achieve the same result by moving it to a CSS file? I cannot find anything...
2
by: Matt | last post by:
In the following code, page1.asp is inside the frame of main.html. When the user click submit button in page1.asp, it will submit the form and open a new window called page2.asp. When the user...
10
by: Dieter Salath? | last post by:
Hi, in our webpage, a user could open a windows explorer to his temp directory with a simple link and usage of the file protocol: <a href="file://C:\temp" target="_blank">C:\temp</a> This...
5
by: Jon via DotNetMonster.com | last post by:
<siteMapNode title="share price" description="Link to Netcall on the London Stock Exchange" url="http://www.yahoo.co.uk" role="" target="_blank" /> Hi all I'm trying to open the Yahoo web...
1
by: =?Utf-8?B?Sko=?= | last post by:
Hi all, I have a help page that I have to (against my better judgement) open up in a new window, which will show the help for the current page the user is on. So in my master page I have a...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.