title: Create dynamic .aspx pages in asp.net
body: <p>The following code creates file.aspx and file.aspx.cs:</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      string fielName = Server.MapPath("~/file.aspx");        
      TextWriter tw = new StreamWriter(fielName);        
      tw.WriteLine(@"&lt;%@ Page Language=""C#"" AutoEventWireup=""true""  CodeFile=""file.aspx.cs"" Inherits=""file"" %&gt;
                     &lt;!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""&gt;
                      &lt;html xmlns=""http://www.w3.org/1999/xhtml""&gt;
                      &lt;head runat=""server""&gt;
                          &lt;title&gt;&lt;/title&gt;
                      &lt;/head&gt;
                      &lt;body&gt;
                          &lt;form id=""form1"" runat=""server""&gt;
                          &lt;div&gt;
  
                          &lt;/div&gt;
                          &lt;/form&gt;
                      &lt;/body&gt;
                      &lt;/html&gt;
                      ");        
      tw.Close();
      tw = new StreamWriter(fielName + ".cs");
  
      tw.WriteLine(@"using System;
                      using System.Collections.Generic;
                      using System.Linq;
                      using System.Web;
                      using System.Web.UI;
                      using System.Web.UI.WebControls;
                      using System.IO;
  
                      public partial class file : System.Web.UI.Page
                      {
                          protected void Page_Load(object sender, EventArgs e)
                          {
                             Response.Write(""new File "");
  
                          }
                      }
                      ");       
      tw.Close();
  }
  </code></pre>
  
  <p>I want to make the page name written in my Textbox.</p>
  
  <p>I have tried putting textbox in html source of above code, but I'm getting an error.</p>
  
  <pre><code>CodeFile="""+TextBox1.Text+""" Inherits="""+TextBox1.Text+"""
  </code></pre>