Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Open a new page in response

Open a new page in response

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadmin
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MasudM
    wrote on last edited by
    #1

    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.

    C 1 Reply Last reply
    0
    • M MasudM

      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.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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!

      M M 2 Replies Last reply
      0
      • C Colin Angus Mackay

        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!

        M Offline
        M Offline
        Megan Forbes
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • M Megan Forbes

          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

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          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 the window.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!

          M 1 Reply Last reply
          0
          • C Colin Angus Mackay

            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 the window.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!

            M Offline
            M Offline
            Megan Forbes
            wrote on last edited by
            #5

            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

            C 1 Reply Last reply
            0
            • M Megan Forbes

              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

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              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!

              M 1 Reply Last reply
              0
              • C Colin Angus Mackay

                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!

                M Offline
                M Offline
                Megan Forbes
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                • C Colin Angus Mackay

                  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!

                  M Offline
                  M Offline
                  MasudM
                  wrote on last edited by
                  #8

                  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:)

                  C 1 Reply Last reply
                  0
                  • M MasudM

                    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:)

                    C Offline
                    C Offline
                    Colin Angus Mackay
                    wrote on last edited by
                    #9

                    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!

                    M 1 Reply Last reply
                    0
                    • C Colin Angus Mackay

                      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!

                      M Offline
                      M Offline
                      MasudM
                      wrote on last edited by
                      #10

                      Thanks Colin. I think that is the bottom line ! That 'll do my work ! :laugh:

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups