0

I was curious if you can pass a vb variable into back end javascript. I have a page that a user can upload a image and a link to that image. I am executing a reader to pull the link from the database and declare a variable as string = to the reader. when i try to pass it into the script with this code

Response.Write("<script>")
Response.Write("window.open(<%= linkLeft %>,'_blank')")
Response.Write("</script>")

it just comes back as my url/linkLeft instead of just the url of the link in the database. Is there any possible way to pass this variable into the script? I havent really came across anything to do this. i am using this because i want the link to open in a new window so response.redirect is out of the question i believe?

Thanks in advance

squinny
  • 79
  • 4
  • 12

1 Answers1

1

I don't know what linkLeft is or where it is defined, so the syntax might be slightly different, but it will be something like this:

Response.Write("window.open('" & linkLeft & "','_blank')")
Dark Falcon
  • 43,592
  • 5
  • 83
  • 98
  • Thanks alot Dark Falcon i had initially tried Response.Write("window.open('" + linkLeft + "','_blank') and it didnt like it. You were right on the money. i REALLY Appreciate it. Thanks! – squinny Dec 18 '12 at 20:26
  • And the result of that was...? By the way, this answer may also interest you: http://stackoverflow.com/questions/3006153/vb-net-ampersand-vs-plus-for-concatenating-string – Dark Falcon Dec 18 '12 at 20:29
  • it wasnt accepting the variable at all its inaccessible due to protection level with the + – squinny Dec 18 '12 at 20:40