无效的回发或回调参数。<pages enableEventValidation="true"/>
使用配置或页面启用事件验证<%@ Page EnableEventValidation="true" %>
。出于安全目的,此功能验证回发或回调事件的参数是否源自最初呈现它们的服务器控件。如果数据有效且符合预期,请使用该ClientScriptManager.RegisterForEventValidation
方法注册回发或回调数据以进行验证。
描述:
当前 Web 请求执行期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详情:
System.ArgumentException:回发或回调参数无效。使用配置或页面中的 <%@ Page EnableEventValidation="true" %> 启用事件验证。出于安全目的,此功能验证回发或回调事件的参数是否源自最初呈现它们的服务器控件。如果数据有效且符合预期,请使用 ClientScriptManager.RegisterForEventValidation 方法注册回发或回调数据以进行验证。
源错误:
在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。
堆栈跟踪:
[ArgumentException:回发或回调参数无效。使用配置或页面中的 <%@ Page EnableEventValidation="true" %> 启用事件验证。出于安全目的,此功能验证回发或回调事件的参数是否源自最初呈现它们的服务器控件。如果数据有效且符合预期,请使用 ClientScriptManager.RegisterForEventValidation 方法注册回发或回调数据以进行验证。]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +144
System.Web.UI .WebControls.Button.RaisePostBackEvent(String eventArgument) +122
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) + 1724
版本信息:
Microsoft .NET Framework 版本:4.0.30319;ASP.NET 版本:4.0.30319.18408
我的源代码(设计)
<asp:Repeater ID="showallposts" runat="server"
onitemcommand="showallposts_ItemCommand"
onitemdatabound="showallposts_ItemDataBound">
<ItemTemplate>
<hr />
<div id="showpostername" style="color:Red;" >
<asp:Label ID="nameofposter" runat="server" Text='<%# Eval("FName") %>' style="font-size:medium;"></asp:Label>
</div>
<div id="showpost" style="background-color:Silver; color:Black; width:auto; height:auto; font-size:small">
<asp:Label ID="postcontent" runat="server" Text='<%# Eval("PostContent") %>'></asp:Label>
<asp:Label ID="postidis" runat="server" Text='<%# Eval("PostID") %>' Visible="false"></asp:Label>
</div>
<div id="textboxandbuttontocomment" style="height:auto;width:auto">
<asp:TextBox ID="commentonposttext" runat="server" TextMode="MultiLine" style="height:40px;width:500px"></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="watermarkforaddcomment" runat="server" TargetControlID="commentonposttext" WatermarkText="Comment"></ajaxToolkit:TextBoxWatermarkExtender>
<br />
<asp:LinkButton ID="linkbutton_show_comments_specific" runat="server" Text="Show Comments" CommandName="showallcommentsofthispost" style="font-size:medium;color:Blue;width:20px;height:20px"></asp:LinkButton>
<asp:Button ID="submitcomment" runat="server" Text="Comment" CommandName="postcommentforthispost" style="left:300px;position:relative " />
</div>
<div id="repeaterinsiderepeater" style="height:auto;width:auto">
<asp:Repeater ID="Rerepeat" runat="server">
<ItemTemplate>
<div id="showcomments_specific" style="height:auto; width:auto">
<asp:Label ID="showspecificcommentslabeltext" runat="server" Text='<%# Eval("CommentContent") %>' style="font-size:small;color:Black;height:auto;width:auto"></asp:Label>
<asp:Label ID="commentpostid" runat="server" Text='<%# Eval("CommentID") %>' Visible="false"></asp:Label>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
我的 .cs 代码
protected void showallposts_ItemCommand(object source, RepeaterCommandEventArgs e)
{
Repeater childrepeater = (Repeater)e.Item.FindControl("Rerepeat");
Label nameofposter = (Label)e.Item.FindControl("nameofposter");
Label postcontent = (Label)e.Item.FindControl("postcontent");
Label postidis = (Label)e.Item.FindControl("postidis");
TextBox commentonposttext = (TextBox)e.Item.FindControl("commentonposttext");
LinkButton linkbutton_show_comments_specific = (LinkButton)e.Item.FindControl("linkbutton_show_comments_specific");
// linkbutton_show_comments_specific.OnClientClick += showcommentsbylink_Click(postidis);
Button submitcomment = (Button)e.Item.FindControl("submitcomment");
// submitcomment.OnClientClick += submitcomment_Click();
Label showspecificcommentslabeltext = (Label)e.Item.FindControl("showspecificcommentslabeltext");
selectedpostid = Convert.ToInt32(postidis.Text);
commentcontent = postcontent.Text;
if (e.CommandName == "postcommentforthispost")
{
submitcomment.OnClientClick += submitcomment_Click();
childrepeater.DataSource = ds;
childrepeater.DataBind();
commentonposttext.Text = "";
}
if (e.CommandName == "showallcommentsofthispost")
{
DataSet ds;
ds = bal.getallrelatedcomments(selectedpostid);
childrepeater.DataSource = ds;
childrepeater.DataBind();
}
}
public DataSet submitcomment_Click()
{
string commentdate = System.DateTime.Now.ToShortDateString();
string commenttime = System.DateTime.Now.ToShortTimeString();
int res = bal.savecomment(selectedpostid,Studid,commentcontent,commentdate,commenttime,firstname,lastname);
if (res > 0)
{
ds = bal.getallrelatedcomments(selectedpostid);
}
return ds;
}