title: Send parameters into dynamically loaded user controls
body: <p>I load the content of some User Controls into my page with the use of jQuery. So I have this function that extracts the content from my User Control, and it works like a charm.</p>
  
  <pre><code>    public string GetObjectHtml(string pathToControl)
      {
          // Create instance of the page control
          Page page = new Page();
  
          // Create instance of the user control
          UserControl userControl = (UserControl)page.LoadControl(pathToControl);
  
          //Disabled ViewState- If required
          userControl.EnableViewState = false;
  
          //Form control is mandatory on page control to process User Controls
          HtmlForm form = new HtmlForm();
  
          //Add user control to the form
          form.Controls.Add(userControl);
  
          //Add form to the page
          page.Controls.Add(form);
  
          //Write the control Html to text writer
          StringWriter textWriter = new StringWriter();
  
          //execute page on server
          HttpContext.Current.Server.Execute(page, textWriter, false);
  
          // Clean up code and return html
          string html = CleanHtml(textWriter.ToString());
  
          return html;
      }
  </code></pre>
  
  <p>But I would really like to send in some parameters into my User Control when I create it. Is this possible, and how can i do that?</p>
  
  <p>I can see that <code>LoadControl()</code> can take some parameters with <code>object[] parameters</code> but im really not sure on how to use it, help much appreciated!</p>