簡體   English   中英

無效的回發或回調參數 - Telerik網格中的按鈕

[英]Invalid postback or callback argument - button in Telerik grid

非常着名的錯誤消息(見下文),根據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>

點擊“取消”按鈕,這是着名的錯誤:

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();
}

在回發上重新綁定網格顯然是搞砸了。 我改成了:

protected void Page_Load(object sender, EventArgs e) {
  if (!IsPostBack) {
    MyGrid.Rebind();
  }
}

現在一切正常。

我有同樣的問題,但我的NeedDataSource方法或Page_Load方法中沒有Grid.Rebind()或Grid.Databind()。 這是在我拖動要分組的列然后對分組列ASC / DESC進行排序之后發生的

我只是補充道

EnableEventValidation="false" 

在我的.aspx頁面的<%@ Page%>標記中。 排序失敗但至少我不再收到錯誤。 作為注釋,除了分組列的排序之外,其他所有內容都可以正常工作

這是我在NeedDataSource方法中使用的代碼

        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        String connstr = ConfigurationManager.ConnectionStrings["PrimeIntegartionsConnectionString"].ConnectionString;

        SqlDataSource Ds = new SqlDataSource(connstr, BuildSql()); //buildsql simply returns a SQLSelect String "select * from example"
        RadGrid1.DataSource = Ds;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM