填充DropDownList的客户端。入门后回来验证错误 [英] Populating dropdownlist client side. Getting post back validation error

查看:97
本文介绍了填充DropDownList的客户端。入门后回来验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个dropdownlists一夏精。当你从第一个选择的东西,二是相应的填充。当回发时,我得到了老:

I have a webcontrol with two dropdownlists on in. When you choose something from the first, the second is populated accordingly. When post back occurs I get the old:

无效的回发或回调参数。事件验证启用
  使用
  配置或LT;%@页
  EnableEventValidation =真正的%>在
  页。为了安全起见,这
  功能验证参数
  回发或回调事件的起源
  从服务器控件
  最初呈现这些。如果数据
  是有效的和期望的,可使用
  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.

我知道这是什么问题;我用填充意外的数据下拉。我上的错误念起来像发现重写Render方法,你所说的RegisterForEventValidation为每一个新的DropDownList项修正。我不能做到这一点,但是,因为我重新填充下拉客户端。

I know what this problem is; I am populating the dropdown with unexpected data. I've read up on the error and found fixes like overriding the Render method where you call "RegisterForEventValidation" for each new dropdownlist item. I can't do this, however, as I am repopulating the dropdown client side.

在理论上我可以用这个方法,如果我说每一个可能的值(约3000),可以被包含在下拉列表中,但我真的不希望这样做。

In theory I could use this method if I added every possible value (around 3000) that could be included in the dropdown, but I didn't really want to do this.

有没有避过此错误,任何其他方式,而无需禁用或EventValidation填充DropDownList的服务器端?

Are there any other ways of getting around this error, without disabling EventValidation or populating the dropdownlist server side?

推荐答案

您可能需要使用一个基本的HTML选择并查找所选值的Request.Form 集合。

You might have to use a basic html select and look for the selected value on the Request.Form collection.

随着 DROPDOWNLIST 恐怕你没有其他选择,只有那些2。

With the DropdownList I'm afraid you have no other option but those 2.

这篇关于填充DropDownList的客户端。入门后回来验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆