非常着名的错误消息(见下文),根据Google搜索结果的数量来判断.但是我见过的每一个人都建议EnableEventValidation去false.我搜索了我的整个代码库,我无法在任何地方找到字符串"EnableEventValidation" .而且,这段代码用来工作; 我所做的事情显然打破了网页.但是什么?
单击Telerik RadGrid内的按钮时发生错误,声明为:
<telerik:RadGrid ID="MyGrid" Width="100%" ItemStyle-BorderColor="Gainsboro"
ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1px" ActiveItemStyle-BackColor="Bisque"
SelectedItemStyle-BackColor="Black" AllowPaging="True" PageSize="15" runat="server"
AllowSorting="true" OnItemCommand="MyGrid_ItemCommand" AutoGenerateColumns="false"
OnNeedDataSource="MyGrid_NeedDataSource" GridLines="Horizontal" AllowMultiRowSelection="false"
Skin="Black">
<GroupingSettings CaseSensitive="false" />
<MasterTableView Width="100%" DataKeyNames="ID" AllowFilteringByColumn="false" Font-Names="Arial"
Font-Size="10px">
<Columns>
<telerik:GridButtonColumn ButtonType="PushButton" Text="Cancel" CommandName="Cancel"
ConfirmText="Are you sure you want to cancel this?">
</telerik:GridButtonColumn>
...
</Columns>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric" />
<FilterMenu EnableTheming="True">
<CollapseAnimation Duration="200" Type="OutQuint" />
</FilterMenu>
</telerik:RadGrid>
Run Code Online (Sandbox Code Playgroud)
点击"取消"按钮,这是着名的错误:
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.
这是问题所在:在我的Page_Load方法中,我有:
protected void Page_Load(object sender, EventArgs e) {
MyGrid.Rebind();
}
Run Code Online (Sandbox Code Playgroud)
在回发上重新绑定网格显然是搞砸了.我改成了:
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
MyGrid.Rebind();
}
}
Run Code Online (Sandbox Code Playgroud)
现在一切正常.
| 归档时间: |
|
| 查看次数: |
8094 次 |
| 最近记录: |