组合框选定项在选定后将被删除.无效的回发或回调参数
本文关键字:回调 参数 无效 组合 删除 | 更新日期: 2023-09-27 18:36:25
我的页面中有四个文本框,一个组合框和一个按钮(以及其他一些控件)。根据文本框中键入的值,将在组合框中更新相关值。单击我页面中的提交按钮时,它给出了以下错误。
"无效的回发或回调参数。在配置或页面中使用启用事件验证。出于安全目的,此功能验证回发或回调事件的参数是否源自最初呈现它们的服务器控件。如果数据有效且预期。使用
ClientScriptManager.RegisterForEventsValidation
方法注册回发或回调数据以进行验证。
现在在我添加的页面指令中
<%@Page EnableEentValidation="false">
当我在四个文本框中键入值时,相应的值将出现在cobobox中。但是当我选择该组合框值时,所选值将被删除。这是什么原因呢?
<%@ Page Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="AddeChecklist.aspx.cs"
Inherits="LabTrack.WebApplication.Echecklist.AddeChecklist" EnableEventValidation ="false" %>
<%@ Register TagPrefix="Labinal" TagName="AutoCompleteControl" Src="~/UserControls/AutoCompleteEnabledWebUserControl.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="../Styles/CheckListRev.css" rel="stylesheet" type="text/css" />
<!-- Style for the page -->
<link href="../Styles/AddeChecklist.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
<asp:Panel ID="ErrorMessagePanel" CssClass="ErrorPanel" Visible="true" runat="server">
<div class="ErrorDiv">
<asp:BulletedList CssClass="ErrorMessage" ID="ErrorMessageBulletedList" runat="server">
</asp:BulletedList>
</div>
</asp:Panel>
<div class="PageTitle">
<asp:Label ID="PageHeaderLabel" runat="server"></asp:Label>
</div>
<div class="MainDiv">
<div style="text-align: center;">
<div class="PlaceHolder">
<table id="formTable">
<tr>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelCustomer" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Customer:</span><br />
<asp:TextBox ID="CustomerNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxCustomerHiddenField" runat="server" />
<asp:Button ID="customerTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelProgram" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Program:</span><br />
<asp:TextBox ID="ProgramNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:Button ID="programTriggerbutton" runat="server" Text="Button" Style="display: none;" />
<asp:HiddenField ID="IxProgramHiddenField" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="customerTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelWorkPackage" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">WorkPackage:</span><br />
<asp:TextBox ID="WorkPackageNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxWorkPackageHiddenField" runat="server" />
<asp:Button ID="workPackageTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="programTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel runat="server" ID="updatepanelActivity" UpdateMode="Conditional">
<ContentTemplate>
<span class="boldLabelLong">Activity:</span><br />
<asp:TextBox ID="ActivityNameTextBox" Width="200" runat="server"></asp:TextBox>
<asp:HiddenField ID="IxActivityHiddenField" runat="server" />
<asp:Button ID="activityTriggerbutton" runat="server" Text="Button" Style="display: none;" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="workPackageTriggerbutton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="activityTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
<div class="PlaceHolder">
<asp:Label ID="TemplateLabel" Text="Template:" CssClass="ControlLabel" runat="server"></asp:Label>
<asp:UpdatePanel runat="server" ID="updatepanelTemplate" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="TemplateSelectDropDownList" runat="server" Width="400" Visible="true"
AutoPostBack="true">
</asp:DropDownList>
<asp:HiddenField ID="IxTemplateHiddenField" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="workPackageTriggerbutton" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Panel ID="SustainPanelTemplateOwner" Visible="true" runat="server">
<div>
<asp:Label ID="TemplateOwnerLabel" Text="Owner:" CssClass="ControlLabel" runat="server"></asp:Label>
<asp:TextBox ID="TemplateOwnerTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
</asp:Panel>
<asp:HiddenField ID="IxDeliverableHiddenField" runat="server" />
<asp:HiddenField ID="IxReleaseActionHiddenField" runat="server" />
<asp:HiddenField ID="IxConfigHiddenField" runat="server" />
<asp:HiddenField ID="IxTemplateOwnerHiddenField" runat="server" />
<asp:HiddenField ID="TemplateSelectedSnameHiddenField" runat="server" />
<asp:HiddenField ID="TemplateOwnerSelectedsNameHiddenField" runat="server" />
<asp:HiddenField ID="DeliverableSelectedHiddenField" runat="server" />
<div>
<asp:Label ID="DeliverableLabel" CssClass="ControlLabel" runat="server" Text="Deliverable:"></asp:Label>
<asp:TextBox ID="DeliverableTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
<asp:Panel ID="SustainPanelConfig" Visible="true" runat="server">
<div>
<asp:Label ID="ConfigurationLabel" runat="server" Text="Configuration:" CssClass="ControlLabel"></asp:Label>
<select id="ConfigurationSelect" class="controlMargin">
<option></option>
</select>
</div>
</asp:Panel>
<asp:Panel ID="SustainPanelRelease" Visible="true" runat="server">
<div>
<asp:Label ID="ReleaseActionLabel" CssClass="ControlLabel" runat="server" Text="Release Action:"></asp:Label>
<asp:TextBox ID="ReleaseActionTextBox" CssClass="controlMargin" Width="400" runat="server"></asp:TextBox>
</div>
</asp:Panel>
<asp:Panel ID="SustainPanel" Visible="true" runat="server">
<div class="SustainPanelControls">
<div>
<asp:Label ID="ChangeLabel" Text="Change #: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="ChangeTextBox" Width="110" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="SupplementLabel" Text="Supplement: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="SupplementTextBox" Width="80" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="NewWrrLabel" Text="WRR #: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="NewWrrTextBox" Width="80" runat="server"></asp:TextBox>
</div>
<div>
<asp:Label ID="DddLabel" Text="3D: " runat="server"></asp:Label>
</div>
<div>
<asp:TextBox ID="DddTextBox" Width="80" runat="server"></asp:TextBox>
</div>
</div>
<div>
<table id="DesignDataTable2">
<tr>
<td>
<asp:Label ID="AllFbSheetsWrrLabel" Text="All F/B Sheets w/WRR #:" CssClass="ControlLabel" runat="server"></asp:Label>
</td>
<td>
<asp:TextBox CssClass="completeControl" ID="AllFbSheetsWrrTextBox" Width="588" Rows="2"
TextMode="MultiLine" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</div>
</asp:Panel>
</div>
<div class="EditButtonGroup">
<input id="EditButton" type="button" value="Edit" class="ButtonSettings" />
<input id="RemoveButton" type="button" value="-" class="ButtonSettings" />
<input id="AddButton" type="button" value="+" class="ButtonSettings" />
</div>
</div>
<div class="ViewData">
<div class="ViewDataDiv">
<table id="DesignDataTable" class="designDataTable">
<tbody>
</tbody>
</table>
</div>
</div>
<div class="submitButtonDiv">
<asp:Button ID="SubmitButton" runat="server" Text="Button Text" class="submitButtonCreateChecklist" />
</div>
</div>
</asp:Content>
您正在客户端创建新值,并将它们发布回服务器。
出于安全原因,ASP.NET 实现"事件验证"。即使启用了验证,如果服务器创建具有 3 个可能值的组合,则只会在回发时接受此值。如果创建其他值并将其发送回服务器,则会收到所引用的错误。
在这里,您有一些信息:Page.EnableEventValidation 属性
如果您知道哪些是在客户端生成的可能值,则可以使用 ClientScriptManager.RegisterForEventValidation 方法,或者如果您事先不知道这些值,则可以完全禁用验证。
要禁用验证:
通过设置 @ Page 指令的 enableEventValidation 属性或 Web.config 文件中页面元素的 enableEventValidation 属性,可以设置 EnableEventValidation 属性。如果在代码中设置此属性,则必须在初始化页面之前设置此属性。
听起来像是视图状态覆盖值的问题。
尝试使用 Request.Form[Dropdown.ClientId]
直接获取值