format Blog

给我个权限,我format你的硬盘.

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

用HttpContext获得Server对象,然后执行Execute方法,看代码:

 

public string RenderView(UserControl control)
{
   Page page
=new Page();
   Form form
=new Form();

   page.Controls.Add(form);
   StringWriter output 
= new StringWriter();
 
   form.Controls.Add(control);
   HttpContext.Current.Server.Execute(page, output, 
false);
 
   
return output.ToString();
}

 

如果是不需要在Form中的控件,我们可以省去添加Form这一步。

posted on 2010-02-22 10:34  format  阅读(329)  评论(0编辑  收藏  举报