不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
"回发或回调参数无效"解决方法
编辑:dnawo 日期:2008-09-06
复制内容到剪贴板
程序代码

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="20">张三</asp:ListItem>
<asp:ListItem Value="21">李四</asp:ListItem>
</asp:DropDownList>
<input id="btn" type="button" value="客户端添加项" onclick="document.getElementById('DropDownList1').add(new Option('王五','22'));" /><br />
<asp:Button ID="Button1" runat="server" Text="提交" OnClick="Button1_Click"></asp:Button>
<asp:ListItem Value="20">张三</asp:ListItem>
<asp:ListItem Value="21">李四</asp:ListItem>
</asp:DropDownList>
<input id="btn" type="button" value="客户端添加项" onclick="document.getElementById('DropDownList1').add(new Option('王五','22'));" /><br />
<asp:Button ID="Button1" runat="server" Text="提交" OnClick="Button1_Click"></asp:Button>
服务器端使用 DropDownList1.SelectedValue 获取选择项的值:
复制内容到剪贴板
程序代码

protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(DropDownList1.SelectedValue);
}
{
Response.Write(DropDownList1.SelectedValue);
}
当选择项是"张三"或"李四"时程序运行正常,当选择项是使用客户端js增加的"王五"时,程序运行出错:
回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page EnableEventValidation="true" %> 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
将EnableEventValidation的值设置为false后,程序不再出错,但在服务器端也无法获取"王五"这一项的值!改用 Request["DropDownList1"] 才能正常获取值:
复制内容到剪贴板
程序代码

protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(Request["DropDownList1"].ToString());
}
{
Response.Write(Request["DropDownList1"].ToString());
}
评论: 0 | 引用: 0 | 查看次数: 4054
发表评论
请登录后再发表评论!