Open a new page in response
-
Hi I wanna to open a new page from the server side in the client. I only know about the Response.Redirect that redirect the response to the another page and does not open a new page. Something like window.open of javascript that opens a new window but that is in the client side.
-
Hi I wanna to open a new page from the server side in the client. I only know about the Response.Redirect that redirect the response to the another page and does not open a new page. Something like window.open of javascript that opens a new window but that is in the client side.
So, what is really happening? YOu have a button that goes back to the server, it changes the current page and at the same time you want it to open a page in a new windows? Yes? If that is the case then you add some javascript to the response that opens the new window. However it is still the client side that is opening the new window and if the user has scripts turned off it won't work. If you don't want the existing page to be updated, but just open a new page in a new window then you can use the
target
attribute on the anchor tag. For example<a href="TheNewPage.aspx" target="_blank">
However, again this is the client side that is opening the new page. Does this help? If not, then perhaps you can explain why it needs to be open from the server side.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
So, what is really happening? YOu have a button that goes back to the server, it changes the current page and at the same time you want it to open a page in a new windows? Yes? If that is the case then you add some javascript to the response that opens the new window. However it is still the client side that is opening the new window and if the user has scripts turned off it won't work. If you don't want the existing page to be updated, but just open a new page in a new window then you can use the
target
attribute on the anchor tag. For example<a href="TheNewPage.aspx" target="_blank">
However, again this is the client side that is opening the new page. Does this help? If not, then perhaps you can explain why it needs to be open from the server side.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
Seeing as you answered that question Colin, can I take it a little further? :) I am using a hyperlinkcolumn in a datagrid (more in a thread below on this page). Currently it's working very nicely thus:
asp:HyperLinkColumn DataNavigateUrlField="business_id" DataNavigateUrlFormatString="javascript:location.replace('../folder/file.asp?BusinessID={0}',null,'width=700,height=500,status=no,scrollbar=yes,toolbar=no,menubar=no,location=no,top=0,left=0, return=false');" DataTextField="reference_number" Target="_blank" HeaderText="VN Reference"
The first thing you'll probably notice is that it's currently opening an ASP page, rather than ASPX - that's because we're busy migrating the existing system over to .NET, while continuing to provide new functionality as well (fun huh? :rolleyes: ) Anyway, this is working very well, the query string value is recieved by the ASP page and everything is great. However, where I'm having a problem is in controlling the menu's and toolbars, width, heigth, etc of the new window opened. Clearly these can no longer be passed as part of the javascript location.replace. However, although the hyperlinkcolumn does have a "target" property, I'm struggling to find a way to pass the new window dimensions across. Have you found any way around this? Thanks :)
Look at the world about you and trust to your own convictions. - Ansel Adams
Meg's World - Blog Photography -
Seeing as you answered that question Colin, can I take it a little further? :) I am using a hyperlinkcolumn in a datagrid (more in a thread below on this page). Currently it's working very nicely thus:
asp:HyperLinkColumn DataNavigateUrlField="business_id" DataNavigateUrlFormatString="javascript:location.replace('../folder/file.asp?BusinessID={0}',null,'width=700,height=500,status=no,scrollbar=yes,toolbar=no,menubar=no,location=no,top=0,left=0, return=false');" DataTextField="reference_number" Target="_blank" HeaderText="VN Reference"
The first thing you'll probably notice is that it's currently opening an ASP page, rather than ASPX - that's because we're busy migrating the existing system over to .NET, while continuing to provide new functionality as well (fun huh? :rolleyes: ) Anyway, this is working very well, the query string value is recieved by the ASP page and everything is great. However, where I'm having a problem is in controlling the menu's and toolbars, width, heigth, etc of the new window opened. Clearly these can no longer be passed as part of the javascript location.replace. However, although the hyperlinkcolumn does have a "target" property, I'm struggling to find a way to pass the new window dimensions across. Have you found any way around this? Thanks :)
Look at the world about you and trust to your own convictions. - Ansel Adams
Meg's World - Blog PhotographyHi Meg, According to my MSDN documentation (I can't seem to find the same document online) The
replace
method on window or document only takes one parameter, the URL. However, the parameter list you have here matches thewindow.open()
method. Could that be the reason?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
Hi Meg, According to my MSDN documentation (I can't seem to find the same document online) The
replace
method on window or document only takes one parameter, the URL. However, the parameter list you have here matches thewindow.open()
method. Could that be the reason?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
Argh! Quite right. As you'll see in this[^] conversation below, I couldn't get window.open to do what I wanted, so I changed to the above tactic. Would have helped if I'd kept what you just said in mind :sigh: Will this bank holiday weekend ever arrive?!
Look at the world about you and trust to your own convictions. - Ansel Adams
Meg's World - Blog Photography -
Argh! Quite right. As you'll see in this[^] conversation below, I couldn't get window.open to do what I wanted, so I changed to the above tactic. Would have helped if I'd kept what you just said in mind :sigh: Will this bank holiday weekend ever arrive?!
Look at the world about you and trust to your own convictions. - Ansel Adams
Meg's World - Blog PhotographyMegan Forbes wrote: Will this bank holiday weekend ever arrive?! I take it you're looking forward to visiting the Lake District? Anyway, at least you get a long weekend. I've just got a normal weekend. On the bonus side, I'm doing training over the next two weeks.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
Megan Forbes wrote: Will this bank holiday weekend ever arrive?! I take it you're looking forward to visiting the Lake District? Anyway, at least you get a long weekend. I've just got a normal weekend. On the bonus side, I'm doing training over the next two weeks.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
Colin Angus Mackay wrote: I'm doing training over the next two weeks mmmm - training! I'm starting to think that'll never happen here :sigh: Colin Angus Mackay wrote: I take it you're looking forward to visiting the Lake District Indeed we are, yes! The only day rain is expected is Sunday, hopefully it'll mostly be nice though. It's just about full moon, we're hoping to camp at Lake Windermere. I should have some nice moonlit shots to post upon our return :cool:
Look at the world about you and trust to your own convictions. - Ansel Adams
Meg's World - Blog Photography -
So, what is really happening? YOu have a button that goes back to the server, it changes the current page and at the same time you want it to open a page in a new windows? Yes? If that is the case then you add some javascript to the response that opens the new window. However it is still the client side that is opening the new window and if the user has scripts turned off it won't work. If you don't want the existing page to be updated, but just open a new page in a new window then you can use the
target
attribute on the anchor tag. For example<a href="TheNewPage.aspx" target="_blank">
However, again this is the client side that is opening the new page. Does this help? If not, then perhaps you can explain why it needs to be open from the server side.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
hi First of all thanks . But you know I actually wanna to do the following thing : on button click of a page I wanna to do some server works to find out where should the response redirect and with what parameters.and then I don't wanna redirect my response to that page I wanna to Open a new page. I know about the window.open() return true; thing but that does not apply in this situation.and also know about the grid asp:HyeperLinkColumn but that dose not either. I think that may not be possible.(this much easy:sigh:)
-
hi First of all thanks . But you know I actually wanna to do the following thing : on button click of a page I wanna to do some server works to find out where should the response redirect and with what parameters.and then I don't wanna redirect my response to that page I wanna to Open a new page. I know about the window.open() return true; thing but that does not apply in this situation.and also know about the grid asp:HyeperLinkColumn but that dose not either. I think that may not be possible.(this much easy:sigh:)
In the button's server-side click event you write the code to determine where the new page should go. You then inject some javascript in your page so that when the page refreshes (yes, it's going to have to refresh the original page at least) the injected javascript code will use window.open to open the new window to the page you want. See also: System.Web.UI.Page.RegisterClientScriptBlock[^] System.Web.UI.Page.RegisterStartupScript[^]
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
-
In the button's server-side click event you write the code to determine where the new page should go. You then inject some javascript in your page so that when the page refreshes (yes, it's going to have to refresh the original page at least) the injected javascript code will use window.open to open the new window to the page you want. See also: System.Web.UI.Page.RegisterClientScriptBlock[^] System.Web.UI.Page.RegisterStartupScript[^]
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!