title: Adding textbox to UserControl in asp.net
body: <p>I have a simple web page which has a UserControl(.ascx). Here is my <strong>UserControl source</strong> </p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucReportTextBox.ascx.cs"
  Inherits="Intranet.UserControl.ucReport" %&gt;
  &lt;table width="100%"&gt;
  &lt;tr&gt;
        &lt;td&gt;
           &lt;asp:TextBox ID="txtQuery" runat="server" Width="250px" /&gt;
        &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And my <strong>web page source</strong></p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/DefaultMasterPage.Master"
  AutoEventWireup="true" CodeBehind="ComposeReport.aspx.cs" Inherits="Intranet.MasterPage.WebForm4" %&gt;
  &lt;%@ Register Src="~/UserControl/UcReportTextBox.ascx" TagName="UcReportTextBox" TagPrefix="uc1" %&gt;
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="contentHead" runat="server"/&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="contentBody" runat="server"&gt;
  &lt;table&gt;
     &lt;tr&gt;
         &lt;td&gt;
             &lt;uc1:UcReportTextBox ID="ucReporttxt" runat="server" /&gt;
         &lt;/td&gt;
     &lt;/tr&gt;
  //includes so many tags
  &lt;/table&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>In <strong>code behind of my web page</strong> </p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          InitComponent();
      }
  
      private void InitComponent()
      {
          XDocument document = XDocument.Load("ReportXML.xml");
          var parameterTypes = document.Descendants("Type");
  
          foreach (var parType in parameterTypes)
          {
              if (parType.Value == "string") //TODO Enumerate it !!
              {
                  ucReporttxt.addTextBox();
              }
          }
      }
  </code></pre>
  
  <p>In <strong>code behind of usercontrol</strong></p>
  
  <pre><code>public void addTextBox() 
      {
          TextBox txtBox = new TextBox();
          txtBox.ID = "txtBox";
          txtBox.Width = 170;
          Page.Form.Controls.Add(txtBox);
      }
  </code></pre>
  
  <p>As you understand I'm newer to asp.net , in PageLoad I'm reading XMLfile to whether or not add textbox to page. The codes add textboxes correctly but the textboxes are added at the end of the page. I want to add textbox at the part of <code>ucReportText</code> not the end of the page how can fix it ?</p>
  
  <p>Thanks for your help.</p>