title: Response.Write() with javascript doesn't work properly
body: <p>I'm having a problem with this code:</p>
  
  <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
      clave = Request.QueryString("cve")
  
      If clave = Nothing Then
          Response.Write("&lt;script language='javascript'&gt;alert('Querystring is empty');window.close();&lt;/script&gt;")
          Return
      End If
  
      Dim valid As Boolean
      valid = Regex.Match(clave, "\b\d{3}\-\d{3}\-\d{3}\b").Success
  
      If valid = False Then
          Response.Write("&lt;script language='javascript'&gt;alert('Wrong format');window.close();&lt;/script&gt;")
          Return
      End If
  
  'More Code
  End Sub
  </code></pre>
  
  <p>The thing is that, the first if statement works fine and the 'javascript' shows an alert and close the window, but in the second if statement the javascript shows the message but doesn't close the window. </p>
  
  <p>Do you guys know how to fix this?</p>