2010-02-13 7 views
0

ProcessRequest(HttpContext context).ashx 파일의 코드 세트 (아래 명시)가 있습니다. 나는 HttpHander에서 오전으로HttpHandler에서 HtmlGenericControl 렌더링

HtmlGenericControl holder = new HtmlGenericControl("div"); 
//Set holder's properties and customization 
HtmlGenericControl button1 = new HtmlGenericControl("input"); 
//Set button1's properties and customization 
holder.Controls.Add(button1); 
HtmlGenericControl button2 = new HtmlGenericControl("input"); 
//Set button2's properties and customization 
holder.Controls.Add(button2); 
HtmlGenericControl button2 = new HtmlGenericControl("input"); 
//Set button2's properties and customization 
holder.Controls.Add(button2); 

지금, 나는 holder 제어의 HTML을 얻고 context.Respose.Write()를 통해 작성합니다.

도와주세요. 사전에
덕분에

Munim는

답변

2

나 자신에 의해 방법을 알아 낸 것.

using (StringWriter stringWriter = new StringWriter()) 
{ 
    HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter); 
    holder.RenderControl(htmlTextWriter); 
    HttpContext.Response.Write(stringWriter.ToString()); 
    htmlTextWriter.Close(); 
    stringWriter.Close(); 
}