Re: UserControl output into an XmlNode

    Date: 08/16/05 (C Sharp)    Keywords: html, xml

    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)
             sb.Append(Convert.ToChar(tmp));
       
          HttpContext.Current.Trace.Write("EditSectionOrAsset",
             "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 '[info]'owenblacker, '[info]'csharp and '[info]'ms_dot_net.

    Source: http://www.livejournal.com/community/csharp/33333.html

« UserControl output into an... || Active Directory and .NET »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home