title: Set text in <p> embedded in asp:Panel from code behind c# asp.net
body: <p>I am trying to add text from my code behind file based on a URL query string. I have an asp:Label that works fine, but I need to add text to the body of an asp:Panel and that is causing my problem. Here is my code:</p>
  
  <p>ASPX file:</p>
  
  <pre><code>&lt;asp:Panel ID="PanelAboutUs" class="panel panel-primary" runat="server"&gt;
      &lt;asp:Panel ID="PanelAboutUsHeader" class="panel-heading panel-success" runat="server"&gt;
          &lt;asp:Label ID="LabelAboutUsHeader" runat="server"&gt;&lt;/asp:Label&gt;
      &lt;/asp:Panel&gt;
  
      &lt;asp:Panel ID="PanelAboutUsBody" class="panel-body" runat="server"&gt;    
          &lt;asp:TextBox ID="TextAboutUsBody" runat="server"&gt;&lt;/asp:TextBox&gt;    
      &lt;/asp:Panel&gt;
  
      &lt;div class="divide-30"&gt;&lt;/div&gt;       
  
      &lt;div class="panel-footer"&gt;
          &lt;div class="form-group"&gt;
              &lt;asp:LinkButton runat="server" Text="Ok" CausesValidation="True" ID="CancelRequest" CssClass="btn btn-lg btn-block btn-success"  OnClick="Ok_OnClick"&gt;&lt;/asp:LinkButton&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>And here is my code behind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      try
      {
          if (!string.IsNullOrEmpty(Request.QueryString["result"]))
              result = int.Parse(Request.QueryString["result"]);
          else Response.Redirect("Default.aspx");
      }
      catch
      {
          Response.Redirect("Default.aspx");
      }
  
      if (result == 0)
      {
          LabelAboutUsHeader.Text = "Cancelled!";
          TextAboutUsBody.Text = "Before you can schedule services you will need to enter a preferred payment method. You can add this payment method the next time you successfully login to your account.";
      }
      else
      {
          LabelAboutUsHeader.Text = "Success!";
          TextAboutUsBody.Text = "Your payment information has been successfully added. To access the system you must first validate your account via the email sent during registration.";
      }
  }
  </code></pre>
  
  <p>The problem is with my <code>asp:TextBox</code>. Originally I had the text hard coded through using <code>&lt;p&gt;</code> instead of <code>asp:TextBox</code> and everything worked fine. But I could not get my <code>&lt;p&gt;</code> to update with dynamic text so I changed to <code>asp:TextBox</code>. The formatting of the <code>asp:TextBox</code> is not working right and only part of my message is actually displaying.</p>
  
  <p>So given all that explanation, my question is how can I make my original code work using <code>&lt;p&gt;</code> but updating from code behind file. Here is my original code.</p>
  
  <pre><code>&lt;asp:Panel ID="PanelAboutUsHeader" class="panel-heading panel-success" runat="server"&gt;
      &lt;asp:Label ID="LabelAboutUsHeader" runat="server"&gt;&lt;/asp:Label&gt;
  &lt;/asp:Panel&gt;
  
  &lt;asp:Panel ID="PanelAboutUsBody" class="panel-body" runat="server"&gt;    
      &lt;p&gt;[Dynamic text from code behind should go here.]&lt;/p&gt;    
  &lt;/asp:Panel&gt;
  </code></pre>