title: How to render a WebUserControl client-side
body: <p>I created a web user control which has some ASP.NET and third-party controls. </p>
  
  <p>I've already tested my control in the markup of a page and it works well.</p>
  
  <pre><code>&lt;APP:MyControl ID="myControl1" InitializeWithValue="Employee" /&gt;
  &lt;APP:MyControl ID="myControl2" InitializeWithValue="Supplier" /&gt;
  </code></pre>
  
  <p>Now, I want to render this control in the same page but not when the page renders at the first time. In fact, I will click a button which will call a callback and in that moment I want to render the control.</p>
  
  <p>I was trying to do something like this.</p>
  
  <pre><code>void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
  {
     MyControl c1 = new MyControl();
     c1.InitializeWithValue = Person.Enum.Employee; //&lt;--CRASH
  
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     System.IO.StringWriter sw = new System.IO.StringWriter(sb);
     HtmlTextWriter hw = new HtmlTextWriter(sw);
     c1.RenderControl(hw);
     return sb.ToString();
  }
  </code></pre>
  
  <p>Then on my client-side receiver </p>
  
  <pre><code>&lt;a href="javascript:void(0);" onclick="testcallback('', '')"&gt;Test&lt;/a&gt;
  &lt;div id="divControls"&gt;&lt;/div&gt;
  
  &lt;script&gt;
      function receiver(arguments, context) {
          document.getElementById('divControls').innerHTML = arguments;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>But it crash at the moment of the initialization because all the inner controls of the WebUserControl are null. They have not been initialized. </p>
  
  <p>This is the property of the control</p>
  
  <pre><code>   [Browsable(true)]
     public Person.Enum InitializeWithValue
     {
        get { return this.enumPersonValue; }
        set
        {
           this.enumPersonValue = value;
           //Literal control
           this.litPersonType.Text = "Employee"; //&lt;-- CRASH because litPersonType is null.
        }
     }
  </code></pre>
  
  <p>Some can help me to correct this or suggest me another way render a web control but client-side?</p>