RenderControl输出html遇到的问题

当我直接在后台用GridView gv=new GridView();gv.RenderControl(htmlwrite);没有问题,但是如果 我从工具直接拖一个GridView到设计页面,在后台gv.RenderControl(htmlwrite);就会出现 Control 'GridViewTotal' of type 'GridView' must be placed inside a form tag with runat =server.这个错误!
解决的办法:在后台添加一个重载方法。
 public override void VerifyRenderingInServerForm(Control control)
    {
        /* Confirms that an HtmlForm control is rendered for the specified ASP.NET
           server control at run time. */
    }


public virtual void VerifyRenderingInServerForm(System.Web.UI.Control control)
    Member of System.Web.UI.Page

Summary:
Confirms that an System.Web.UI.HtmlControls.HtmlForm control is rendered for the specified ASP.NET server control at run time.

Parameters:
control: The ASP.NET server control that is required in the System.Web.UI.HtmlControls.HtmlForm control.

Exceptions:
System.Web.HttpException: The specified server control is not contained between the opening and closing tags of the System.Web.UI.HtmlControls.HtmlForm server control at run time.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值