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. Opening page in new window

Opening page in new window

Scheduled Pinned Locked Moved ASP.NET
helptutorialdesignsysadmin
7 Posts 4 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.
  • T Offline
    T Offline
    TofuBug24
    wrote on last edited by
    #1

    I've given myself a headache trying to figure this out so i'm just posting it hoping to find an answer basicly to sumarize i have a composite control which contains a LinkButton who's text is an E-Mail address I wrote an Event handler that passes out the Text of the LinkButton finally i dropped a public event into the toolbar for easy design time support. It's then up to the developer using the composite control to decide how to use the E-mail address (i.e. passing to a mailto: protocol or using a hard coded smtp mail client in the code) now to the problem: I need to be able to open up a new window when the user clicks on the LinkButton while leaving the original window intact. now as an example of something i've tried in my event handler: Resonse.Redirect("mailto:" + (Entry.AnEntry)sender).Email,false); ^ ^ Control Name Text Property the only problem is the page loads in the same window I've tried Server.Transfer but it gives me an error since the mailto: protocol is not located on the server Now i already know i could just use a hyperlink with the page set to _blank but i need to be able to do some preprocessing before i open up the new window (hence the LinkButton) Hope to hear from someone on this soon Ryan

    J N R 3 Replies Last reply
    0
    • T TofuBug24

      I've given myself a headache trying to figure this out so i'm just posting it hoping to find an answer basicly to sumarize i have a composite control which contains a LinkButton who's text is an E-Mail address I wrote an Event handler that passes out the Text of the LinkButton finally i dropped a public event into the toolbar for easy design time support. It's then up to the developer using the composite control to decide how to use the E-mail address (i.e. passing to a mailto: protocol or using a hard coded smtp mail client in the code) now to the problem: I need to be able to open up a new window when the user clicks on the LinkButton while leaving the original window intact. now as an example of something i've tried in my event handler: Resonse.Redirect("mailto:" + (Entry.AnEntry)sender).Email,false); ^ ^ Control Name Text Property the only problem is the page loads in the same window I've tried Server.Transfer but it gives me an error since the mailto: protocol is not located on the server Now i already know i could just use a hyperlink with the page set to _blank but i need to be able to do some preprocessing before i open up the new window (hence the LinkButton) Hope to hear from someone on this soon Ryan

      J Offline
      J Offline
      Javier Lozano
      wrote on last edited by
      #2

      TofuBug24 wrote: I need to be able to open up a new window when the user clicks on the LinkButton while leaving the original window intact. What are you trying to do by opening the window? I'm a little confused as what you're trying to accomplish with your control. ~Javier Lozano (blog)

      T 1 Reply Last reply
      0
      • J Javier Lozano

        TofuBug24 wrote: I need to be able to open up a new window when the user clicks on the LinkButton while leaving the original window intact. What are you trying to do by opening the window? I'm a little confused as what you're trying to accomplish with your control. ~Javier Lozano (blog)

        T Offline
        T Offline
        TofuBug24
        wrote on last edited by
        #3

        Say someone clicks on the LinkButton and the code that was added in the event handler sends the e-mail address which is the text property of that link button to a mailto: protocol for example response.redirect("mailto:someemailaddress@someserver.com",false) i also have a LinkButton in the same composite control who's text property contains a web site address that will always be external to the server that the runnin page is on. same problem with that private void AnEntry1_WebLinkButtonClicked(sender object, EventArgs e) { // do some stuff before opening new web page like adding cache or session objects Respone.Redirect("http://www.TheTextPropertyOfTheWebLinkButton.com,false); } or for the e-mail private void AnEntry1_EmailLinkButtonClicked(sender object, EventArgs e) { // do some stuff before sending e-mail like incrementing a count of sent e-mails into a // database located on the server, or add default e-mail fields not provided by the user // subject, signature etc. Response.Redirect("mailto:TheTextPropertyOf@TheWebLinkButton.com,false); } now both examples above i don't want it to close the original window my page is running on just open a new one to either navigate to the external website or send out an e-mail using the mailto: protocol the way i'm reading it Response.Redirect with false as the second parameter should do the trick but they still open in the same window Hope this clears up the confusion drop me a line if you need to know more Ryan

        1 Reply Last reply
        0
        • T TofuBug24

          I've given myself a headache trying to figure this out so i'm just posting it hoping to find an answer basicly to sumarize i have a composite control which contains a LinkButton who's text is an E-Mail address I wrote an Event handler that passes out the Text of the LinkButton finally i dropped a public event into the toolbar for easy design time support. It's then up to the developer using the composite control to decide how to use the E-mail address (i.e. passing to a mailto: protocol or using a hard coded smtp mail client in the code) now to the problem: I need to be able to open up a new window when the user clicks on the LinkButton while leaving the original window intact. now as an example of something i've tried in my event handler: Resonse.Redirect("mailto:" + (Entry.AnEntry)sender).Email,false); ^ ^ Control Name Text Property the only problem is the page loads in the same window I've tried Server.Transfer but it gives me an error since the mailto: protocol is not located on the server Now i already know i could just use a hyperlink with the page set to _blank but i need to be able to do some preprocessing before i open up the new window (hence the LinkButton) Hope to hear from someone on this soon Ryan

          N Offline
          N Offline
          Noman Nadeem
          wrote on last edited by
          #4

          Hello Ryan, The Response.Redirect is used for redirecting the current window to a new location (as the name suggests). you should try the following:

          Response.Write("window.open("mailto:" + (Entry.AnEntry)sender).Email,null,null) ");

          hope this is useful, regards, Noman Nadeem :zzz:

          T 1 Reply Last reply
          0
          • T TofuBug24

            I've given myself a headache trying to figure this out so i'm just posting it hoping to find an answer basicly to sumarize i have a composite control which contains a LinkButton who's text is an E-Mail address I wrote an Event handler that passes out the Text of the LinkButton finally i dropped a public event into the toolbar for easy design time support. It's then up to the developer using the composite control to decide how to use the E-mail address (i.e. passing to a mailto: protocol or using a hard coded smtp mail client in the code) now to the problem: I need to be able to open up a new window when the user clicks on the LinkButton while leaving the original window intact. now as an example of something i've tried in my event handler: Resonse.Redirect("mailto:" + (Entry.AnEntry)sender).Email,false); ^ ^ Control Name Text Property the only problem is the page loads in the same window I've tried Server.Transfer but it gives me an error since the mailto: protocol is not located on the server Now i already know i could just use a hyperlink with the page set to _blank but i need to be able to do some preprocessing before i open up the new window (hence the LinkButton) Hope to hear from someone on this soon Ryan

            R Offline
            R Offline
            ramip
            wrote on last edited by
            #5

            try this string sJavaScript = "\r"; sJavaScript += "window.open('mailto:" + TheEmailFromSender + "');\r"; sJavaScript += ""; Page.RegisterStartupScript("Redirect", sJavaScript);

            1 Reply Last reply
            0
            • N Noman Nadeem

              Hello Ryan, The Response.Redirect is used for redirecting the current window to a new location (as the name suggests). you should try the following:

              Response.Write("window.open("mailto:" + (Entry.AnEntry)sender).Email,null,null) ");

              hope this is useful, regards, Noman Nadeem :zzz:

              T Offline
              T Offline
              TofuBug24
              wrote on last edited by
              #6

              Thanks so much for the help I feel kind of bad saying this but at first i couldn't get it to work which was pissing me off cause i've used the whole window.open java script many times before (the Response.Write was pretty much what i was clueless on) after a few hours of banging my head of my monitors i finally smacked my head hard enough to realize window.open() takes a string not an object. to add insult to injury I've been coding in C# for so long i completely forgot that in Javascript a string is surrounded in '' not "" so for another 2 hours the lack of those two dang tickmarks mocked me. finally i clued in and Everything worked beautifuly. I hope you don't feel insulted by me posting a slight correction to your post. But code-project's message boards have helped me more than once sort through some tough spots in my development projects and i feel obligated to do my best to ensure that anyone else who happens along these post's looking for an answer to their question doesn't get confused with the syntax. for anyone reading this thread here's how i finally got the dang thing working for my Email link button: Response.Write("window.open("'mailto:" + ((Entry.AnEntry).Email + "')"); and for my website link button: Response.Write("window.open("'http://" + ((Entry.AnEntry).Web + "','WebsiteWindow')"); Thanks once again for the help i really appreciate it Ryan

              N 1 Reply Last reply
              0
              • T TofuBug24

                Thanks so much for the help I feel kind of bad saying this but at first i couldn't get it to work which was pissing me off cause i've used the whole window.open java script many times before (the Response.Write was pretty much what i was clueless on) after a few hours of banging my head of my monitors i finally smacked my head hard enough to realize window.open() takes a string not an object. to add insult to injury I've been coding in C# for so long i completely forgot that in Javascript a string is surrounded in '' not "" so for another 2 hours the lack of those two dang tickmarks mocked me. finally i clued in and Everything worked beautifuly. I hope you don't feel insulted by me posting a slight correction to your post. But code-project's message boards have helped me more than once sort through some tough spots in my development projects and i feel obligated to do my best to ensure that anyone else who happens along these post's looking for an answer to their question doesn't get confused with the syntax. for anyone reading this thread here's how i finally got the dang thing working for my Email link button: Response.Write("window.open("'mailto:" + ((Entry.AnEntry).Email + "')"); and for my website link button: Response.Write("window.open("'http://" + ((Entry.AnEntry).Web + "','WebsiteWindow')"); Thanks once again for the help i really appreciate it Ryan

                N Offline
                N Offline
                Noman Nadeem
                wrote on last edited by
                #7

                appologies for the mistyping the code. I should've copy/pasted from my code instead of writing it myself. I feel really bad about your wasted time, maybe someday I'll be able to make it up to you. take care regards, Noman Nadeem :zzz:

                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