我在花式框中有一个注册表单作为内联内容,并且可以在所有站点中访问它,因为链接位于母版页中。
在注册表单上,我有两个下拉列表,一个用于国家,另一个用于城市。当用户更改国家/地区时,城市下拉列表会刷新为先前选择的国家/地区。我从脚本https://bdhacker.wordpress.com/tag/all-countries-of-the-world/获得的来自国家和城市的所有数据
问题是,当用户提交表单时,Firefox 中会出现错误提示
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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: 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.
正如错误指出的那样,我必须设置 enableeventvalidation=false。问题是我必须在每个页面上都这样做,因为fancybox 在整个站点中,而且我读到它不是最佳安全实践。当异常抛出时,其他选项是使用两个下拉列表的客户端脚本管理器注册每个选项,这会很烦人,因为有 200 多个国家和 10.000 个城市!
有什么想法我能做什么?
这是一些代码
<%@ Master Language="C#" AutoEventWireup="True" CodeBehind="Site.master.cs" Inherits="VozDirecta.SiteMaster" %>
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
$("#RegistroLightbox").fancybox({
});
});
</script>
<body id="page1">
<form id="Form1" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="server">
</asp:ScriptManager>
<a class="labelsTipolinks" id="RegistroLightbox" href="#LightBoxRegistroDiv">Registro</a>
<div style="display: none">
<div id="LightBoxRegistroDiv">
<asp:DropDownList ValidationGroup="grupoValidacionRegistroUsuario" runat="server"
ID="drpDownPais" CssClass="textoLightbox" AutoPostBack="false" CausesValidation="false">
</asp:DropDownList>
<asp:DropDownList ValidationGroup="grupoValidacionRegistroUsuario" runat="server"
ID="drpDownCiudad" CssClass="textoLightbox" AutoPostBack="false" CausesValidation="false">
</asp:DropDownList>
</div>
</div>
我考虑其他选择从数据库中获取数据并绑定到下拉列表,但我宁愿留在 javascript