ポストバックまたはコールバック引数が無効です。<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;
}