Insert HTML at CodeBehind, WebForm C#?
<p>i have a method that generate tools based on the number value inserted, and I have another control called "DateTimePicker" that does the job of providing a textbox and the date+time picker function.</p>

<p>However, now the problem is that when i call dynamic_tools method and inserted the value "4" and "addInfoPanel" to the method.</p>

<p>The html code does not generating anything in the panel.</p>

<p>But, when i tried this html, it works. </p>

<pre><code>lit.Text = @"&lt;div class='errorMessage'&gt;The user ID or password you entered does not match our records. Please try again. &lt;br /&gt;
                        You may also securely recover your &lt;a href='#'&gt;User ID&lt;/a&gt; or reset your &lt;a href='#'&gt;Password&lt;/a&gt; online.
                    &lt;/div&gt;";
</code></pre>

<p>I'm not too sure what is the reason behind this. I'm suspecting whether is it because of the custom control that i have created? any help is much appreciated. Thanks</p>

<p>Here's the code:</p>

<p>DateTimePicker.ascx.cs -> taken from <a href="https://github.com/jiestrada/DateTimePicker" rel="nofollow">https://github.com/jiestrada/DateTimePicker</a></p>

<pre><code>using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class DateTimePicker : System.Web.UI.UserControl
{
    public string DateTime
    {
        get { return txtDateTime.Text; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        DateTimePicker picker = this;
        ScriptManager.RegisterClientScriptBlock(picker, picker.GetType(), "message", "&lt;script type=\"text/javascript\" language=\"javascript\"&gt;getDateTimePicker();&lt;/script&gt;", false);
    }
}
</code></pre>

<p>DateTimePicker.ascx -> taken from <a href="https://github.com/jiestrada/DateTimePicker" rel="nofollow">https://github.com/jiestrada/DateTimePicker</a></p>

<pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="DateTimePicker.ascx.cs"
    Inherits="DateTimePicker" %&gt;
&lt;style type="text/css"&gt;
    .textBox
    {
        width: 150px;
        border-radius: 4px 4px 4px 4px;
        color: #555555;
        display: inline-block;
        font-size: 14px;
        height: 20px;
        line-height: 20px;
        margin-bottom: 10px;
        padding: 4px 6px;
        vertical-align: middle;
        background-color: #FFFFFF;
        border: 1px solid #CCCCCC;
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
        transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
        font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
    }
&lt;/style&gt;

&lt;script type="text/javascript" language="javascript"&gt;
    function getDateTimePicker()
    {
       $('#datetimepicker').DateTimePickerNew({
            format: 'dd/MM/yyyy hh:mm:ss',
            language: 'en'
      });
    }
&lt;/script&gt;

&lt;div id="datetimepicker" class="input-append date"&gt;
    &lt;asp:TextBox ID="txtDateTime" CssClass="textBox" runat="server"&gt;&lt;/asp:TextBox&gt;
    &lt;span class="add-on"&gt;&lt;i data-time-icon="icon-time" data-date-icon="icon-calendar"&gt;&lt;/i&gt;
    &lt;/span&gt;
&lt;/div&gt;

&lt;script type="text/javascript" language="javascript"&gt;
       $('#datetimepicker').DateTimePickerNew({
            format: 'dd/MM/yyyy hh:mm:ss',
            language: 'en'
      });
&lt;/script&gt;
</code></pre>

<p>Dynamic Tools Method</p>

<pre><code> protected string dynamic_tools(int key, PlaceHolder panel)
    {

    if (key == 4)
    {
    string value = "dtp"+i;

    Literal lit = new Literal();

    lit.Text = @"&lt;td&gt;&lt;DateTime:DateTimePicker ID='DateTimePicker' runat='server' /&gt;&lt;/td&gt;";
    panel.Controls.Add(lit);


    }

    }
</code></pre>

<p>HTML CODE</p>

<pre><code>&lt;%@ Register Src="~/Control/DateTimePicker.ascx" TagName="DateTimePicker" TagPrefix="DateTime" %&gt;

&lt;div id="wrapper"&gt;


     &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
     &lt;/asp:ScriptManager&gt;

     &lt;asp:UpdatePanel ID="singtelUpdatePanel" runat="server" UpdateMode="Conditional"&gt;


                &lt;ContentTemplate&gt;

                     &lt;asp:PlaceHolder ID="addInfoPanel" runat="server" Visible="false"&gt;&lt;/asp:PlaceHolder&gt;

                &lt;/ContentTemplate&gt;


     &lt;/asp:UpdatePanel&gt;
&lt;/div&gt;
</code></pre>