title: sending a variable from code-behind to .aspx
body: <p><br>
  How I can send a variable from code-behaind to .aspx file :</p>
  
  <p>code-behind:<br>
  variable <strong>FilePathName</strong></p>
  
  <p>.aspx:</p>
  
  <pre><code>&lt;body&gt;
  &lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
      &lt;asp:TextBox ID="TextBox1" runat="server" Text="Label"&gt;&lt;/asp:TextBox&gt;
      &lt;frameset cols="100%,*"&gt;
          &lt;frame name="main" target="main" src="FilePathName"&gt;
      &lt;/frameset&gt;
  
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>How I can send FilePathName to src in .aspx  </p>
  
  <p>Thanks,<br>
  Ahmed.</p>
  
  <p><em><strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**<em></strong> U P D A T E <strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**</strong><br>
  This is Code-Behind and my goal is to open .pdf file in a frame so that I can open together with another .htm page in one window:</p>
  
  <pre><code>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
      Dim sFilePath As String
      Dim buffer As Byte()
      Using con As New SqlConnection()
          con.ConnectionString = ConfigurationManager.ConnectionStrings()("SqlServerConnection").ConnectionString
          con.Open()
          Using cmd As New SqlCommand("SELECT imageLaw FROM Laws WHERE ID = @ID", con)
              Dim pID As New SqlParameter("@ID", SqlDbType.Int)
              pID.Value = CType(Request.QueryString("pID"), Integer)
              cmd.Parameters.Add(pID)
              buffer = cmd.ExecuteScalar()
          End Using
          con.Close()
      End Using
      sFilePath = System.IO.Path.GetTempFileName()
      System.IO.File.Move(sFilePath, System.IO.Path.ChangeExtension(sFilePath, ".pdf"))
      sFilePath = System.IO.Path.ChangeExtension(sFilePath, ".pdf")
      System.IO.File.WriteAllBytes(sFilePath, buffer)
      'Literal1.Text = "&lt;frame  src=\"" + sFilePath + " \ "&gt;"
  
      'TextBox1.Text = sFilePath
      ' ''Response.WriteFile(sFilePath)
      ' ''Response.End()
      ' ''Response.BinaryWrite(buffer)
      'Dim act As Action(Of String) = New Action(Of String)(AddressOf OpenFilePW)
      'act.BeginInvoke(sFilePath, Nothing, Nothing)
  End Sub
  
  Private Shared Sub OpenFilePW(ByVal sFilePath As String)
  
      Using p As New System.Diagnostics.Process
          p.StartInfo = New System.Diagnostics.ProcessStartInfo(sFilePath)
          p.Start()
          p.WaitForExit()
          Try
              System.IO.File.Delete(sFilePath)
          Catch
          End Try
      End Using
  End Sub
  </code></pre>
  
  <p>I'm remarking last rows because I don't want .pdf file to be opened outside the web page.  </p>