Invalid postback or callback argument. Event validation is enabled using ''

后端 未结 30 1339
生来不讨喜
生来不讨喜 2020-11-22 05:08

I am getting the following error when I post back a page from the client-side. I have JavaScript code that modifies an asp:ListBox on the client side.

How do we fix

相关标签:
30条回答
  • 2020-11-22 05:16

    Four minutes ago I received the same error. Then I have researched during one half hour like you. In all forums they are generally saying "add page enableEvent..=false or true". Any solution proposed didn't resolved my problems until I found it. The problem is unfortunately an ASP.NET button. I removed it two seconds ago. I tried to replace with "imagebutton", but it was also unacceptable (because it gave the same error).

    Finally I have replaced with LinkButton. it seems to be working!

    0 讨论(0)
  • 2020-11-22 05:16

    Best option to do is use hidden field and do not disable event validation, also change every listbox, dropdownlist to select with runat server attribute

    0 讨论(0)
  • 2020-11-22 05:18

    I had a similar issue, but I was not using ASP.Net 1.1 nor updating a control via javascript. My problem only happened on Firefox and not on IE (!).

    I added options to a DropDownList on the PreRender event like this:

    DropDownList DD = (DropDownList)F.FindControl("DDlista");
    HiddenField HF = (HiddenField)F.FindControl("HFlista");
    string[] opcoes = HF.value.Split('\n');
    foreach (string opcao in opcoes) DD.Items.Add(opcao);
    

    My "HF" (hiddenfield) had the options separated by the newline, like this:

    HF.value = "option 1\n\roption 2\n\roption 3";
    

    The problem was that the HTML page was broken (I mean had newlines) on the options of the "select" that represented the DropDown.

    So I resolved my my problem adding one line:

    DropDownList DD = (DropDownList)F.FindControl("DDlista");
    HiddenField HF = (HiddenField)F.FindControl("HFlista");
    string dados = HF.Value.Replace("\r", "");
    string[] opcoes = dados.Split('\n');
    foreach (string opcao in opcoes) DD.Items.Add(opcao);
    

    Hope this help someone.

    0 讨论(0)
  • 2020-11-22 05:20

    In this case add id to the button in RowDataBound of the grid. It will solve your problem.

    0 讨论(0)
  • 2020-11-22 05:21

    We ran into this same issue when we were converting our regular ASPX pages to Content pages.

    The page with this issue had a </form> tag within one of the Content sections, thus two form end tags were rendered at run time which caused this issue. Removing the extra form end tag from the page resolved this issue.

    0 讨论(0)
  • 2020-11-22 05:22

    One other way not mentioned here is to subclass ListBox

    Ie.

    public class ListBoxNoEventValidation : ListBox 
    {
    }
    

    ClientEventValidation keys off the attribute System.Web.UI.SupportsEventValidation if you subclass it, unless you explicitly add it back in, it will never call the validation routine. That works with any control, and is the only way I've found to "disable" it on a control by control basis (Ie, not page level).

    0 讨论(0)
提交回复
热议问题