【发布时间】:2010-02-23 18:00:34
【问题描述】:
我有以下非常简单的形式:
<asp:UpdatePanel ID="ClaimRewardsForm" runat="server">
<ContentTemplate>
<span class="largeBold">Select jacket weight:</span><br />
<asp:RadioButtonList runat="server" ID="JacketWeight">
<asp:ListItem Value="Lightweight" Text="Lightweight (fleece)" />
<asp:ListItem value="Heavyweight" Text="Heavyweight (cotton)" />
</asp:RadioButtonList>
<br />
<span class="largeBold">Select size:</span><br />
(Men's sizes only)<br />
<asp:DropDownList ID="JacketSize" runat="server">
<asp:ListItem Value="Small" Text="Small" />
<asp:ListItem Value="Medium" Text="Medium" />
<asp:ListItem Value="Large" Text="Large" />
</asp:DropDownList><br />
<br />
<asp:ImageButton ID="SubmitButton" runat="server" ImageUrl = "~/Content/Images/submitButton.png" onclick="SubmitButton_Click" />
</ContentTemplate>
</asp:UpdatePanel>
在我的按钮的点击处理程序中,我有:
protected void SubmitButton_Click(object sender, EventArgs e)
{
if (IsValid)
{
using (var work = UnitOfWorkFactory.Create())
{
var id = new Guid(Session["id"].ToString());
var account = UserAccounts.Get(id);
if (account == null)
throw new Exception("Invalid user account id.");
account.RewardInfo.Clear();
account.RewardInfo.Add(new RewardInfo()
{
UserAccount = account,
JacketWeight = JacketWeight.SelectedValue,
JacketSize = JacketSize.SelectedValue
});
work.Commit();
}
//ClaimRewardsForm.Update();
//ScriptManager.RegisterStartupScript(this, GetType(),
// "confirmation", "ClaimRewards.showConfirmation();", true);
}
}
我没有以任何方式修改表单字段,但我仍然收到以下错误:
505|error|500|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.|
由于我在回发期间根本没有修改控件,所以我终其一生都无法弄清楚为什么它的行为就像我已经修改过一样。有什么想法吗?
【问题讨论】:
-
您使用的是什么版本的 ASP.Net?我似乎记得有一个版本在 UpdatePanel 中的验证控件存在问题,您必须下载不同的 validators.dll ... 请参见此处:blogs.msdn.com/mattgi/archive/2007/05/12/…
-
这给了我一个很好的例子,演练和解释。 couldbedone.blogspot.com/2007/09/…
标签: asp.net updatepanel