By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Redirect and Target="_blank"

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.