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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Open new window without javascript

Open new window without javascript

Scheduled Pinned Locked Moved ASP.NET
helpcsharpjavascriptdatabase
10 Posts 5 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.
  • S Offline
    S Offline
    Sandraa
    wrote on last edited by
    #1

    Hi all, I will try explain you my problem. I have file pdf in a field of my database of SQ-Server. I have a master page and content. I want two options: or open new page for see pdf with focus in it or response.redirect into content. I get open my pdf with:

    Protected Sub gridView\_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView.SelectedIndexChanged
        Try
            If GridView.SelectedIndex >= 0 Then
                Response.Redirect("~/Formularios/VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text)
            End If
        Catch ex As Exception
    
        End Try
    End Sub
    

    but it open all pdf in my master page losing my main menu etc, open my pdf to full page. i would like to open the pdf in a content of master page but doesn't work i put the code of "visorficheros.aspx" that open my pdf from database

    Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Dim id As Integer = Request.QueryString("Id")
            Dim imagedata() As Byte = Ficheros.ObtenerContenidoFichero(id)
            Response.ClearContent()
            Response.ContentType = "application/pdf"
            Response.AddHeader("content-length", imagedata.Length.ToString())
            Response.BinaryWrite(imagedata)
            Response.Flush()
            Response.Close()
        Catch ex As Exception
        End Try
    End Sub
    

    Some idea? also I will try to open with javascript with window.open (I don't like it I prefer that my code be only vb.net without javascript) I put the code:

    Protected Sub gridView\_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView.SelectedIndexChanged
        Try
            If GridView.SelectedIndex >= 0 Then
                'Response.Write("<script language='JavaScript'>window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "')</script>"
            End If
        Catch ex As Exception
        End Try
    End Sub
    

    but I have 2 problem, the first more important is that I.E block it because is a pop-up and the second problem is that I lost the focus and it is put behind of master page. Is possible to make it without javascript, vbscript etc only with vb.net? some idea? thanks for your help, I am becoming madwoman with it X|

    C 1 Reply Last reply
    0
    • S Sandraa

      Hi all, I will try explain you my problem. I have file pdf in a field of my database of SQ-Server. I have a master page and content. I want two options: or open new page for see pdf with focus in it or response.redirect into content. I get open my pdf with:

      Protected Sub gridView\_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView.SelectedIndexChanged
          Try
              If GridView.SelectedIndex >= 0 Then
                  Response.Redirect("~/Formularios/VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text)
              End If
          Catch ex As Exception
      
          End Try
      End Sub
      

      but it open all pdf in my master page losing my main menu etc, open my pdf to full page. i would like to open the pdf in a content of master page but doesn't work i put the code of "visorficheros.aspx" that open my pdf from database

      Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          Try
              Dim id As Integer = Request.QueryString("Id")
              Dim imagedata() As Byte = Ficheros.ObtenerContenidoFichero(id)
              Response.ClearContent()
              Response.ContentType = "application/pdf"
              Response.AddHeader("content-length", imagedata.Length.ToString())
              Response.BinaryWrite(imagedata)
              Response.Flush()
              Response.Close()
          Catch ex As Exception
          End Try
      End Sub
      

      Some idea? also I will try to open with javascript with window.open (I don't like it I prefer that my code be only vb.net without javascript) I put the code:

      Protected Sub gridView\_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView.SelectedIndexChanged
          Try
              If GridView.SelectedIndex >= 0 Then
                  'Response.Write("<script language='JavaScript'>window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "')</script>"
              End If
          Catch ex As Exception
          End Try
      End Sub
      

      but I have 2 problem, the first more important is that I.E block it because is a pop-up and the second problem is that I lost the focus and it is put behind of master page. Is possible to make it without javascript, vbscript etc only with vb.net? some idea? thanks for your help, I am becoming madwoman with it X|

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can't launch a new page with vb.net, at all. It runs on the server. An anchor tag with target='_blank' will open a new page, this new page can be passed an id on the URL, and generate/return/whatever your PDF

      Christian Graus Driven to the arms of OSX by Vista.

      S 1 Reply Last reply
      0
      • C Christian Graus

        You can't launch a new page with vb.net, at all. It runs on the server. An anchor tag with target='_blank' will open a new page, this new page can be passed an id on the URL, and generate/return/whatever your PDF

        Christian Graus Driven to the arms of OSX by Vista.

        S Offline
        S Offline
        Sandraa
        wrote on last edited by
        #3

        where I put target='_blank' ? if I put it into windows.open is the same I.E will block it because it believes that is pop-up and into response.redirect is not possible. sorry I don't understand your solve.

        P T 2 Replies Last reply
        0
        • S Sandraa

          where I put target='_blank' ? if I put it into windows.open is the same I.E will block it because it believes that is pop-up and into response.redirect is not possible. sorry I don't understand your solve.

          P Offline
          P Offline
          Perspx
          wrote on last edited by
          #4

          You put target="_blank" in the A tag, eg:

          <a href="page.html" target="_blank">link</a>

          And since you have no control over IE's popup blocker there's not much else you can do if it's blocked. Regards, --Perspx

          "A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year."
          -Andrew Tanenbaum
          "Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer."
          -Fred Brooks

          S 1 Reply Last reply
          0
          • P Perspx

            You put target="_blank" in the A tag, eg:

            <a href="page.html" target="_blank">link</a>

            And since you have no control over IE's popup blocker there's not much else you can do if it's blocked. Regards, --Perspx

            "A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year."
            -Andrew Tanenbaum
            "Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer."
            -Fred Brooks

            S Offline
            S Offline
            Sandraa
            wrote on last edited by
            #5

            sorry but I don't have

            <a href="page.html" target="_blank">link</a>

            I have

            Response.Write("<script language='JavaScript'>window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "',target='_blank' )</script>")

            but it is the same that

            Response.Write("<script language='JavaScript'>window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "')</script>")

            I don't see any diferent, I.E continue block and with I.E.6 the focus is into master page and not into new window for me is important make it without window.open because i.e block it. For sample if I make it with a linkbutton work well the window.open (doesn't block i.e) but I don't know like do it with into my event gridView_SelectedIndexChanged, any idea? thanks for all

            P G 2 Replies Last reply
            0
            • S Sandraa

              sorry but I don't have

              <a href="page.html" target="_blank">link</a>

              I have

              Response.Write("<script language='JavaScript'>window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "',target='_blank' )</script>")

              but it is the same that

              Response.Write("<script language='JavaScript'>window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "')</script>")

              I don't see any diferent, I.E continue block and with I.E.6 the focus is into master page and not into new window for me is important make it without window.open because i.e block it. For sample if I make it with a linkbutton work well the window.open (doesn't block i.e) but I don't know like do it with into my event gridView_SelectedIndexChanged, any idea? thanks for all

              P Offline
              P Offline
              Perspx
              wrote on last edited by
              #6

              You can use the JavaScript location.href property as follows:

              location.href = [URL];

              to open the page in the current window. Regards, --Perspx

              "A refund for defective software might be nice, except it would bankrupt the entire software industry in the first year."
              -Andrew Tanenbaum
              "Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer."
              -Fred Brooks

              1 Reply Last reply
              0
              • S Sandraa

                sorry but I don't have

                <a href="page.html" target="_blank">link</a>

                I have

                Response.Write("<script language='JavaScript'>window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "',target='_blank' )</script>")

                but it is the same that

                Response.Write("<script language='JavaScript'>window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "')</script>")

                I don't see any diferent, I.E continue block and with I.E.6 the focus is into master page and not into new window for me is important make it without window.open because i.e block it. For sample if I make it with a linkbutton work well the window.open (doesn't block i.e) but I don't know like do it with into my event gridView_SelectedIndexChanged, any idea? thanks for all

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                When you use the window.open method the second parameter is the target, and you can't name the parameters in a function call.

                Response.Write("window.open('VisorFicheros.aspx?Id=" + gridView.SelectedRow.Cells(1).Text + "','_blank');")

                Despite everything, the person most likely to be fooling you next is yourself.

                1 Reply Last reply
                0
                • S Sandraa

                  where I put target='_blank' ? if I put it into windows.open is the same I.E will block it because it believes that is pop-up and into response.redirect is not possible. sorry I don't understand your solve.

                  T Offline
                  T Offline
                  Tarun Dudhatra
                  wrote on last edited by
                  #8

                  Add target="_blenk" attribute in A href tag link below link Click Got it? Techie From Surat

                  S 1 Reply Last reply
                  0
                  • T Tarun Dudhatra

                    Add target="_blenk" attribute in A href tag link below link Click Got it? Techie From Surat

                    S Offline
                    S Offline
                    Sandraa
                    wrote on last edited by
                    #9

                    If I put _blank I don't see diferent. My first problem is that I don't want to use javascript, I want to use only vb.net (asp.net) and my second problem is that when I see that with response.redirect I can't open a new page I have that use javascript with windows.open, with it i can open a new window for me is not necessary the attrib _blank, this is not my problem my problem later with windows.open are 2 the firs and more important is that I.E block my page because is a pop-up, I can't say to all users that unblock it because this is internet :) I need to give a solution by code that not depend of user. My second problem with windows.open is that sometime the focus is lost and I see my main page and not my new window (I can see it if I tabulate). Thanks for your help.

                    T 1 Reply Last reply
                    0
                    • S Sandraa

                      If I put _blank I don't see diferent. My first problem is that I don't want to use javascript, I want to use only vb.net (asp.net) and my second problem is that when I see that with response.redirect I can't open a new page I have that use javascript with windows.open, with it i can open a new window for me is not necessary the attrib _blank, this is not my problem my problem later with windows.open are 2 the firs and more important is that I.E block my page because is a pop-up, I can't say to all users that unblock it because this is internet :) I need to give a solution by code that not depend of user. My second problem with windows.open is that sometime the focus is lost and I see my main page and not my new window (I can see it if I tabulate). Thanks for your help.

                      T Offline
                      T Offline
                      Tarun Dudhatra
                      wrote on last edited by
                      #10

                      There is no other way to open a new window other then any client side script. You have to use either Javascript or vbscript.

                      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