Render Control to HTML String. VerifyRenderingInServerForm Method

原创 2007年09月19日 17:35:00

Sometimes you can get "...must be placed inside a form tag with runat=server" error, when you deal with "asp:panel" or "asp:linkbutton" or whatever else scenarious when html form control needs to be rendered for the specified control at run time. The problem can be solved (thanks, Alex) ovverriding Page.VerifyRenderingInServerForm Method. Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.


So, the code would look like the following (rendering asp:panel containing controls itself):


private void Page_Load(object sender, EventArgs e) 
{
    StringWriter stringWriter = new StringWriter();
    HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
    contentPanel.RenderControl(htmlWriter);
    string s = stringWriter.ToString();

    Response.Write(s);
    Response.End();
}


public override void VerifyRenderingInServerForm(Control control) 
{
    return;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Q9.5 Write a method to compute all permutations of a string

Q:Write a method to compute all permutations of a string A:为了处理方便,下面的代码不是求一个string的全排列,而是求数组的全排列,本质...

OpenGL&CG技术之Render To Texture

使用OpenGL+CG语言,详细讲解了Render To Texture的过程

paper about climbing string method

  • 2014-07-15 16:23
  • 3.40MB
  • 下载

render to texture 事例代码

  • 2016-12-20 10:45
  • 4.85MB
  • 下载

OpenGL ES 学习教程(十四) 帧缓冲区对象(FBO) 实现渲染到纹理(Render To Texture/RTT)

一般情况下,我们只需要系统提供的帧缓冲区作为绘图表面,但是又有些特殊情况,比如阴影贴图、动态反射、处理后特效等需要渲染到纹理(Render To Texture/RTT)操作的,如果使用系统提供的帧缓...

渲染到纹理(Render To Texture, RTT)详解

RTT是现在很多特效里面都会用到的一项很基本的技术,实现起来很简单,也很重要。但是让人不解的是网上搜索了半天只找到很少的文章说这个事儿,不知道是因为太简单还是因为这项技术已经出现很长时间了。总之我是在...

Failed to mount component: template or render function not defined. 错误的解决方法

Vue.js 2 遇到 vue.runtime.common.js?d43f:511 [Vue warn]: Failed to mount component: template or render...

Tutorial 14 : Render To Texture

render to texture
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)