也许我做得不对(如果是的话,请告诉我),但我的脑袋撞到了墙上,好像有一个非常简单的概念。
此呈现覆盖来自用户控件。

protected override void Render(HtmlTextWriter writer)
{
    string htmlAboutToBeRendered = writer.GetWhatHasBeenWrittenToTheWriterSoFar();

    // Do something nefarious, yet unrelated with htmlAboutToBeRendered
}

这似乎是一种显而易见的方式,但我似乎找不到它。
有谁能帮我解释一下这个问题吗?

最佳答案

试试这个:

protected override void RenderContents(HtmlTextWriter output)
{
   StringBuilder sb = new StringBuilder();
   HtmlTextWriter htw = new HtmlTextWriter(new System.IO.StringWriter(sb,
   System.Globalization.CultureInfo.InvariantCulture));
   foreach (Control ctrl in Controls)
   {
      ctrl.RenderControl(htw);
   }
  string strContents = sb.ToString();

}

10-07 17:53