2015-04-23 41 views
2

我使用的JavaScript将在下拉列表列表中的项目添加列表项,当我点击提交按钮,我得到这个错误无效的回发或回调参数,而在下拉列表

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.  

以下是我的代码

<asp:DropDownList ID="dropdownlist" runat="server"></asp:DropDownList> 

<script> 
     var arr = "john,bob,david".split(','); 
     for (var i = 0; i < arr.length; i++) { 
      $('#dropdownlist').append('<option value="'+arr[i]+'">'+arr[i]+'</option>'); 
     } 
</script> 

我知道这个问题已经被问到,但没有解决方案为我工作。

+1

什么是“行”?以及为什么你有'ddServeMeasure',但在JS使用'#dropdownlist'?并在哪里提交按钮? _sidenote_:你不需要'arr = new Array()'如果之后立即你做'arr =“john,bob,david”.split(',');' – Grundy

+2

[Invalid postback or callback argument。事件验证使用'<页enableEventValidation =“true”/>']启用(http://stackoverflow.com/questions/228969/invalid-postback-or-callback-argument-event-validation-is-enabled-using-页面) – Grundy

+0

_解决方案无法为我工作._您尝试了什么,以及您的意思是什么_not wokred_?错误还是什么? – Grundy

回答

0

我无法解决这个问题,但我找到了替代方法。

而不是使用asp dropdownlist我使用html作为相同的目的,并使用Request对象来获取服务器端的值。

相关问题