2012-10-13 53 views

回答

1

這很可能是該問題的作者自己創建的一些代碼。要做到這一點自己作爲一個擴展方法,你可以去:

public static string RenderControl(this Control control) 
{ 
    StringBuilder stringBuilder = new StringBuilder(); 

    using(StringWriter stringWriter = new StringWriter(stringBuilder)) 
    { 
     using(Html32TextWriter htmlWriter = new Html32TextWriter(stringWriter)) 
     { 
      control.RenderControl(htmlWriter); 
      return stringBuilder.ToString(); 
     } 
    } 
} 

參考:http://weblogs.asp.net/srkirkland/archive/2007/11/05/dynamically-render-a-web-user-control.aspx