Re: UserControl output into an XmlNode

A continuation of my awkward question for any C# geeks reading.

Ok, I don’think I’m gonna find a convenient way to do it the way I’d hoped, so I’ve started thinking about rendering the control into a Stream and XmlDocument.Load-ing that Stream into my XmlNode hierarchy.

Except I’m not getting anything out using Control.RenderControl(HtmlTextWriter):

   public XmlDocument RenderXmlDocument()
      MemoryStream stream = new MemoryStream();
      this.RenderControl(new HtmlTextWriter(new StreamWriter(stream)));
      byte[] streamContents = stream.ToArray();
      System.Text.StringBuilder sb = new System.Text.StringBuilder();
      foreach (byte tmp in streamContents)
         "Rendered control as \n\n[" + sb.ToString() + "]");
      XmlDocument control = new XmlDocument();
      control.Load(new XmlTextReader(new StreamReader(stream)));
      return control;

and nothing is getting written to the Trace.

Am I gonna have to work out how to do this without using the control?

Any and all suggestions gratefully received. Cross-posted to , and .



Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s