告诉编译器控件是如何显式呈现的

告诉编译器控件是如何显式呈现的

本文介绍了告诉编译器控件是如何显式呈现的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

告诉编译器通过覆盖VerifyRenderingInServerForm事件显式呈现控件。







Tell compiler that the control is rendered explicitly by overriding the VerifyRenderingInServerForm event.



public override void VerifyRenderingInServerForm(Control control)
{
    /* Verifies that the control is rendered */
}





现在有人如何使用此代码?



添加此项后我收到此错误



Does someone now how to use this code?

when adding this i get this error

Error	2	'Cv.Knowit.GenerateCv.GenerateCvUserControl.VerifyRenderingInServerForm(System.Web.UI.Control)': no suitable method found to override	C:\Users\Administrator\Documents\Visual Studio 2010\Projects\Cv.Knowit\Cv.Knowit\GenerateCv\GenerateCvUserControl.ascx.cs	1350	30	Cv.Knowit





我发现这段代码也是





I found this code also

// Override the Render method to ensure that this control 
// is nested in an HtmlForm server control, between a <form runat=server> 
// opening tag and a </form> closing tag. 
protected override void Render(HtmlTextWriter writer) {
    // Ensure that the control is nested in a server form. 
    if (Page != null) {
        Page.VerifyRenderingInServerForm(this);
    }
    base.Render(writer);
}





我应该如何使用它?



现在我发现如果我把公共部分类GenerateCvUserControl:System.Web.UI.Page

它工作但现在我得到错误



How should i use it ?

Now i found out that if i put public partial class GenerateCvUserControl : System.Web.UI.Page
It works but now i get the error

Line 8:  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GenerateCvUserControl.ascx.cs" Inherits="Cv.Knowit.GenerateCv.GenerateCvUserControl" %>





因为之前它是这样的

公共部分类GenerateCvUserControl:UserControl



Because before it was like this
public partial class GenerateCvUserControl : UserControl

推荐答案

Line 8:  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GenerateCvUserControl.ascx.cs" Inherits="Cv.Knowit.GenerateCv.GenerateCvUserControl" %>





添加属性



Add the attribute

EnableEventValidation="false"


这篇关于告诉编译器控件是如何显式呈现的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 06:52