<i id='I5eBK'><tr id='I5eBK'><dt id='I5eBK'><q id='I5eBK'><span id='I5eBK'><b id='I5eBK'><form id='I5eBK'><ins id='I5eBK'></ins><ul id='I5eBK'></ul><sub id='I5eBK'></sub></form><legend id='I5eBK'></legend><bdo id='I5eBK'><pre id='I5eBK'><center id='I5eBK'></center></pre></bdo></b><th id='I5eBK'></th></span></q></dt></tr></i><div id='I5eBK'><tfoot id='I5eBK'></tfoot><dl id='I5eBK'><fieldset id='I5eBK'></fieldset></dl></div>
    <bdo id='I5eBK'></bdo><ul id='I5eBK'></ul>
  • <legend id='I5eBK'><style id='I5eBK'><dir id='I5eBK'><q id='I5eBK'></q></dir></style></legend>

        <tfoot id='I5eBK'></tfoot>

        <small id='I5eBK'></small><noframes id='I5eBK'>

      1. 使用 JavaScript 重新排列的 ListBox 元素导致回发时发生事件验证错误

        ListBox elements rearranged with JavaScript causing event validation error on postback(使用 JavaScript 重新排列的 ListBox 元素导致回发时发生事件验证错误)

        <i id='r03vx'><tr id='r03vx'><dt id='r03vx'><q id='r03vx'><span id='r03vx'><b id='r03vx'><form id='r03vx'><ins id='r03vx'></ins><ul id='r03vx'></ul><sub id='r03vx'></sub></form><legend id='r03vx'></legend><bdo id='r03vx'><pre id='r03vx'><center id='r03vx'></center></pre></bdo></b><th id='r03vx'></th></span></q></dt></tr></i><div id='r03vx'><tfoot id='r03vx'></tfoot><dl id='r03vx'><fieldset id='r03vx'></fieldset></dl></div>

              <bdo id='r03vx'></bdo><ul id='r03vx'></ul>
              <tfoot id='r03vx'></tfoot>

                <legend id='r03vx'><style id='r03vx'><dir id='r03vx'><q id='r03vx'></q></dir></style></legend>

                    <tbody id='r03vx'></tbody>
                • <small id='r03vx'></small><noframes id='r03vx'>

                  本文介绍了使用 JavaScript 重新排列的 ListBox 元素导致回发时发生事件验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一个包含两个列表框和一些按钮的项目交换器控件,这些按钮允许我在两个列表之间交换项目.交换是使用javascript完成的.我还在列表中上下移动项目.基本上,当我将项目移动到右侧的列表框时,我将元素(GUID)的数据键存储在隐藏字段中.在回发时,我只是从现场读取 GUID.一切正常,但在回发时,我得到以下异常:

                  I have created an item swapper control consisting in two listboxes and some buttons that allow me to swap items between the two lists. The swapping is done using javascript. I also move items up and down in the list. Basically when I move the items to the list box on the right I store the datakeys of the elements (GUIDs) in a hiddenfield. On postback I simply read the GUIDs from the field. Everything works great but on postback, I get the following exception:

                  回发或回调参数无效.使用配置中或页面中的 <%@ Page EnableEventValidation="true" %> 启用事件验证.出于安全目的,此功能验证回发或回调事件的参数是否源自最初呈现它们的服务器控件.如果数据有效且符合预期,请使用 ClientScriptManager.RegisterForEventValidation 方法注册回发或回调数据以进行验证.

                  Invalid postback or callback argument. Event validation is enabled using 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.

                  我已经准备了一个测试应用程序.您所要做的就是下载存档并运行项目.在网页上选择 3 个项目,按全部添加,然后将第三个元素上移一级,然后点击按钮".错误会出现.关闭事件验证是绝对不能接受的.谁能帮帮我,我已经花了两天时间没有找到解决方案.

                  I've prepared a test application. All you have to do is download the archive and run the project. On the web page select the 3 items, press Add all, then move the third element up one level and then hit "Button". The error will show up. Turning event validation off is by no means acceptable. Can anyone help me, I've spent two already days without finding a solution.

                  测试申请

                  推荐答案

                  第一个选项会带来相当大的开销.我已经定义了我自己的从列表框类派生的自定义列表框控件,并执行了 loadpostback 数据的覆盖:

                  The first option will bring considerable overhead. I have defined my own custom listbox control derived from the listbox class and performed an override of the loadpostback data:

                  public class CustomListBox : ListBox
                  {
                      protected override bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
                      {
                          return true;
                      }
                  }
                  

                  在我的用户控件中使用它而不是常规列表框解决了问题,但是我的方法是否存在任何风险?

                  Using this instead of the regular listbox in my user control solved the problem, however are there any risks associated with my approach?

                  这篇关于使用 JavaScript 重新排列的 ListBox 元素导致回发时发生事件验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                  How do I get at the listbox item#39;s quot;keyquot; in c# winforms app?(如何获取列表框项目的“键?在 c# winforms 应用程序中?)
                  <tfoot id='YD3Gw'></tfoot>

                • <i id='YD3Gw'><tr id='YD3Gw'><dt id='YD3Gw'><q id='YD3Gw'><span id='YD3Gw'><b id='YD3Gw'><form id='YD3Gw'><ins id='YD3Gw'></ins><ul id='YD3Gw'></ul><sub id='YD3Gw'></sub></form><legend id='YD3Gw'></legend><bdo id='YD3Gw'><pre id='YD3Gw'><center id='YD3Gw'></center></pre></bdo></b><th id='YD3Gw'></th></span></q></dt></tr></i><div id='YD3Gw'><tfoot id='YD3Gw'></tfoot><dl id='YD3Gw'><fieldset id='YD3Gw'></fieldset></dl></div>

                • <small id='YD3Gw'></small><noframes id='YD3Gw'>

                  • <bdo id='YD3Gw'></bdo><ul id='YD3Gw'></ul>
                        <tbody id='YD3Gw'></tbody>
                    1. <legend id='YD3Gw'><style id='YD3Gw'><dir id='YD3Gw'><q id='YD3Gw'></q></dir></style></legend>