Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had an experience with DataGrid. One of it's columns was "Select" button. When I was clicking "Select" button of any row I had received this error message:</p> <blockquote> <p>"Invalid postback or callback argument. Event validation is enabled using in configuration or &lt;%@ 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."</p> </blockquote> <p>I changed several codes, and finally I succeeded. My experience route:</p> <p>1) I changed page attribute to <code>EnableEventValidation="false"</code>. <strong><em>But it didn't work.</em></strong> (not only is this dangerous for security reason, my event handler wasn't called: <code>void Grid_SelectedIndexChanged(object sender, EventArgs e)</code></p> <p>2) I implemented <code>ClientScript.RegisterForEventValidation</code> in Render method. <strong><em>But it didn't work.</em></strong></p> <pre><code>protected override void Render(HtmlTextWriter writer) { foreach (DataGridItem item in this.Grid.Items) { Page.ClientScript.RegisterForEventValidation(item.UniqueID); foreach (TableCell cell in (item as TableRow).Cells) { Page.ClientScript.RegisterForEventValidation(cell.UniqueID); foreach (System.Web.UI.Control control in cell.Controls) { if (control is Button) Page.ClientScript.RegisterForEventValidation(control.UniqueID); } } } } </code></pre> <p>3) I changed my button type in grid column from <code>PushButton</code> to <code>LinkButton</code>. <strong><em>It worked!</em></strong> ("ButtonType="LinkButton"). I think if you can change your button to other controls like "LinkButton" in other cases, it would work properly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload