无效的回发或回调参数。只得到在图像按钮案例

问题描述:

我收到以下错误:

无效的回发或回调参数。网页enableEventValidation =真/> 在配置或<%@页EnableEventValidation =真正的%&GT事件验证使用&LT启用; 在一个页面。为了安全起见,此功能验证参数回发或回调事件,从最初呈现这些事件的服务器控件。如果数据是有效的和预期,使用ClientScriptManager.RegisterForEventValidation方法来注册回发或回调数据以进行验证。

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

我有一个的ImageButton 转发是这样的:

<asp:ImageButton ID="btn_CreatePdf" ImageUrl="~/images/download.png" 
                 ToolTip="Create Transmittal for this Contact" 
                 CommandName="CreatePdf"   
                 CommandArgument='<%#Eval("contactid")%>' runat="server" />

在以往我点击这个的ImageButton ,它会导致错误。

When ever I click on this ImageButton, it causes that error.

但是,当我试图的LinkBut​​ton 而不是的ImageButton ,它的正常工作。我尝试以下的LinkBut​​ton

But when I tried LinkButton instead of ImageButton, it's working fine. I tried following LinkButton :

<asp:LinkButton ID="btn_CreatePdf" Text="Download" CommandName="CreatePdf" 
                CommandArgument='<%#Eval("contactid")%>' runat="server" >    
</asp:LinkButton>

请给我一个解决方案,我为什么只在以下情况下收到此错误的ImageButton

Please give me a solution, why I'm getting this error only in case of ImageButton.

在的IsPostBack你的页面加载检查

In your page load check of IsPostBack

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        //your code here
    }
}