我在更新面板中使用了一个下拉列表。我设置了所需的条件,但它仍然导致完整的回发。我搜索并尝试了我得到的所有东西,但它仍然坚持错误。
当我更改选定的索引时,它会导致整页发布并显示错误(由火灾错误)
Sys.WebForms.PageRequestManagerServerErrorException:
Sys.WebForms.PageRequestManagerServerErrorException: 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.' when calling method
:[nsIDOMEventListener::handleEvent]
这是我的代码
<asp:ToolkitScriptManager ID="ToolkitScriptManager1"
runat="server" EnablePageMethods="true" EnablePartialRendering="true">
</asp:ToolkitScriptManager>
更新面板代码
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" >
<ContentTemplate>
<table cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td>
<asp:DropDownList ID="DDLCity" runat="server" CausesValidation="false" AutoPostBack="True" OnSelectedIndexChanged="DDLCity_SelectedIndexChanged"
Width="200px">
</asp:DropDownList>
</td>
<td>
<asp:Label ID="Label19" runat="server" Text="Pin Code"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtPinCode" runat="server" Height="20px" ReadOnly="True" ToolTip="Pin Code"
Width="100px"></asp:TextBox>
<asp:TextBoxWatermarkExtender ID="TxtPinCode_TextBoxWatermarkExtender" runat="server"
Enabled="True" TargetControlID="TxtPinCode" WatermarkCssClass="WaterMark" WatermarkText="XXXXXX">
</asp:TextBoxWatermarkExtender>
<asp:RequiredFieldValidator ID="RFVINCODE" runat="server" ControlToValidate="txtarea"
ErrorMessage="Pin Code Required" Text="*">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label17" runat="server" Text="State"></asp:Label>
</td>
<td>
<asp:DropDownList ID="ddlstate" runat="server" Height="24px" OnSelectedIndexChanged="ddlstate_SelectedIndexChanged"
ToolTip="State" Width="200px">
<asp:ListItem>State</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DDLCity" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
请帮我解决这个问题
我也尝试过这种情况,但这也不起作用。
protected override void Render(HtmlTextWriter writer)
{
ClientScript.RegisterForEventValidation(DDLCity.UniqueID.ToString());
ClientScript.RegisterForEventValidation(txtarea.UniqueID.ToString());
ClientScript.RegisterForEventValidation(ddlstate.UniqueID.ToString());
base.Render(writer);
}