我收到以下错误:
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
在Repeater
像这样:
<asp:ImageButton ID="btn_CreatePdf" ImageUrl="~/images/download.png"
ToolTip="Create Transmittal for this Contact"
CommandName="CreatePdf"
CommandArgument='<%#Eval("contactid")%>' runat="server" />
每当我点击这个 ImageButton
,它会导致该错误。
但是当我尝试 LinkButton
而不是 ImageButton
,它工作正常。我尝试关注 LinkButton
:
<asp:LinkButton ID="btn_CreatePdf" Text="Download" CommandName="CreatePdf"
CommandArgument='<%#Eval("contactid")%>' runat="server" >
</asp:LinkButton>
请给我一个解决方案,为什么我只在 ImageButton
的情况下收到此错误? .
最佳答案
在您的页面加载 IsPostBack 检查
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//your code here
}
}
关于c# - 回发或回调参数无效。仅在图像按钮的情况下获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11095312/