- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在使用 gridview 单击按钮时出现以下错误
Server Error in '/' Application.
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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: 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.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: 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.]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +144
System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +29
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
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
当我在 gridview 中按下一个按钮时会发生这种情况,奇怪的是我有另一个 gridview,在运行不同代码的列中也有自定义按钮,但没有给出错误。以下是页面和代码隐藏的代码。
namespace CCCC
{
public partial class drivermangement : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
{
if (Roles.IsUserInRole("Administrator"))
{
LoggedInUser.Value = Convert.ToString(Request.QueryString["driver"]);
}
else
{
LoggedInUser.Value = Membership.GetUser().UserName.ToString();
}
DayOfTheWeekHiddenField.Value = Convert.ToString(Request.QueryString["dow"]);
}
else
{
Response.Redirect("default.aspx");
}
if (NewCustomersGrid.Rows.Count == 0)
{
NewCustomersLabel.Visible = false;
}
else
{
NewCustomersLabel.Visible = true;
}
if (NeedCompostGrid.Rows.Count == 0)
{
NeedCompostLabel.Visible = false;
}
else
{
NeedCompostLabel.Visible = true;
}
if (CanceledGrid.Rows.Count == 0)
{
CanceledLabel.Visible = false;
}
else
{
CanceledLabel.Visible = true;
}
if (VacationGrid.Rows.Count == 0)
{
VacationLabel.Visible = false;
}
else
{
VacationLabel.Visible = true;
}
if (NewCustomersGrid0.Rows.Count == 0)
{
NewCustomersLabel0.Visible = false;
}
else
{
NewCustomersLabel0.Visible = true;
}
if (NeedCompostGrid0.Rows.Count == 0)
{
NeedCompostLabel0.Visible = false;
}
else
{
NeedCompostLabel0.Visible = true;
}
if (CanceledGrid0.Rows.Count == 0)
{
CanceledLabel0.Visible = false;
}
else
{
CanceledLabel0.Visible = true;
}
}
protected void NewCustomerDoneButton_Click(object sender, EventArgs e)
{
int CustomerID = Convert.ToInt32(((Button)sender).CommandArgument);
string CustomerBinNeedAcknowledged = "Yes";
string strConnString = "Data Source";
using (SqlConnection con = new SqlConnection(strConnString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE Customers SET CustomerBinNeedAcknowledged=@CustomerBinNeedAcknowledged WHERE CustomerID=@CustomerID";
cmd.Parameters.AddWithValue("@CustomerBinNeedAcknowledged", CustomerBinNeedAcknowledged);
cmd.Parameters.AddWithValue("@CustomerId", CustomerID);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
和实际页面:
<%@ Master Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" Inherits="CCCCCC.drivermangement" CodeBehind="drivermangement.master.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:HiddenField ID="LoggedInUser" runat="server" />
<asp:HiddenField ID="DayOfTheWeekHiddenField" runat="server" />
<ajaxToolkit:TabContainer ID="RoutingTabs" runat="server" ActiveTabIndex="0"
Width="900px">
<ajaxToolkit:TabPanel runat="server" HeaderText="Pre-Route" ID="PreRouteTab">
<ContentTemplate>
<br />
<asp:Label ID="NewCustomersLabel" runat="server"
style="font-weight: 700; font-size: large; color: #009933" Text="New Customers"></asp:Label>
<asp:GridView ID="NewCustomersGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
DataKeyNames="CustomerId" DataSourceID="NewCustomers" ForeColor="Black"
GridLines="Vertical">
<AlternatingRowStyle BackColor="#99FF99" ></AlternatingRowStyle>
<Columns>
<asp:BoundField DataField="CustomerFullName" HeaderText="Name"
SortExpression="CustomerFullName" />
<asp:BoundField DataField="CustomerFullAddress" HeaderText="Address"
SortExpression="CustomerFullAddress" />
<asp:BoundField DataField="CustomerNeedsBin" HeaderText="Needs Bin?"
SortExpression="CustomerNeedsBin" />
<asp:TemplateField ShowHeader="False"><ItemTemplate>
<asp:Button ID="NewCustomerDoneButton" runat="server" CommandName=""
Text="Done" CommandArgument='<%# Eval("CustomerID") %>' OnClick="NewCustomerDoneButton_Click" CausesValidation="False" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<asp:SqlDataSource ID="NewCustomers" runat="server"
ConnectionString="<%$ ConnectionStrings:tcc_customersConnectionString %>"
SelectCommand="SELECT [CustomerId], [CustomerStatus], [CustomerFullName], [CompanyName], [CustomerFullAddress], [CustomerPickUpDay], [CustomerPickUpDay2], [CustomerDriver], [CustomerNeedsBin], [CustomerBinNeedAcknowledged] FROM [Customers] WHERE (([CustomerBinNeedAcknowledged] = @CustomerBinNeedAcknowledged) AND ([CustomerNeedsBin] = @CustomerNeedsBin) AND ([CustomerDriver] = @CustomerDriver) AND ([CustomerStatus] = @CustomerStatus) AND ([CustomerPickUpDay] = @CustomerPickUpDay OR [CustomerPickUpDay2] = @CustomerPickUpDay2))"><SelectParameters>
<asp:Parameter DefaultValue="No" Name="CustomerBinNeedAcknowledged" Type="String" />
<asp:Parameter DefaultValue="Yes" Name="CustomerNeedsBin" Type="String" />
<asp:ControlParameter ControlID="LoggedInUser" Name="CustomerDriver"
PropertyName="Value" Type="String"></asp:ControlParameter>
<asp:Parameter DefaultValue="New" Name="CustomerStatus" Type="String" />
<asp:ControlParameter ControlID="DayOfTheWeekHiddenField" Name="CustomerPickUpDay"
PropertyName="Value" Type="String" ></asp:ControlParameter>
<asp:ControlParameter ControlID="DayOfTheWeekHiddenField"
Name="CustomerPickUpDay2" PropertyName="Value" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel runat="server" HeaderText="Post-Route" ID="PostRouteTab"><ContentTemplate>
我现在想知道,这与 GridView
位于 Ajax Tab Container
内有什么关系吗?因为我的另一张工作正常的 table 不是......
注意:由于字符限制,不得不从页面中删除一些代码
最佳答案
1) GridView 中无效的回发或回调参数 问题可能是:您正在将 Page_Load 事件中的数据与对象数据源或手动绑定(bind)与函数调用绑定(bind)。这将使您的 GridView 在任何控件的每个事件触发时绑定(bind)数据。
当您使用 OnRowCommand 触发任何 GridView 命令时,在 RowCommand 触发之前,您的 GridView 将重新绑定(bind)并且其中的所有控件都将分配给新的 ID。所以 RowCommand 无法获取触发事件的项目。
GridView 中无效回发或回调参数的解决方案:您可以在此 if 条件中绑定(bind)您的数据
if (!IsPostBack)
{
//Your code for Bind data
}
这段代码肯定会给你解决方案,如果这不起作用,然后检查是否有任何其他控件没有给出错误。
关于c# - 错误 : Invalid postback or callback argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12444946/
在我的上一个项目中,我使用了 rxJava,我意识到 observable.doOnError('onErrorCallback').subscribe(action) 和 observable.su
我是一名 C++ 初学者,我认为要真正学习指针和引用,我应该尝试创建一个回调函数,这是我在 JavaScript 中认为理所当然的事情。 但是,对于我的一生,我不知道为什么这些括号在 (*callba
我在库中有一个类,它具有在事件发生时执行的“onMessage”方法。 OnMessage 在执行时需要调用属于主应用程序中的类的“回调”方法。我假设这将通过构造函数完成,但我不知道它是如何实现的。
两者的 jQuery 文档基本上说明了相同的事情,所以我想知道两者之间是否有任何重大差异(如果有的话)。谢谢! 最佳答案 这方面的文档实际上非常糟糕,所以这是我在 studying the sourc
这个问题在这里已经有了答案: Using &&'s short-circuiting as an if statement? (6 个答案) Omitting the second expressi
我正在尝试在 golang 中定义一个回调: package main func main() { x, y := "old x ", "old y" callback
我有一个页面,其中包含从 Google 电子表格生成的许多图表。 典型代码如下所示: var url = "http://my.googlespreadsheet.com/tq?argumentshe
当我运行 linter 时,它显示: subscribe is deprecated: Use an observer instead of an error callback 代码来自 this a
对于异步套接字 // accept ... listener.BeginAccept( new AsyncCallback(AcceptCallback), listener); // listene
我希望能够根据在前面的函数中调用的是 callback(true) 还是 callback(false) 在回调函数中执行一些逻辑。 示例: foo.doFunction = function (pa
从 jQuery.scrollTo.js 库中看到这个 block (在 v1.4 的第 184 行)。 function animate( callback ){ $elem.animate
我正在尝试在我的应用中使用一些回调,它与 "callback(value)" 和 "callback.invoke(value)" 一起工作正确调用回调。 我想知道“回调(值)”是否只是一个缩短版本,
我决定从 keras 切换到 tf.keras(建议使用 here)。因此我安装了 tf.__version__=2.0.0和 tf.keras.__version__=2.2.4-tf .在我的旧版
我认为这实际上可能会回答我关于 Stack Overflow 的另一个问题如果我能确认这一点。 返回回调和只调用回调有什么区别? 我看到代码执行其中之一/或/两者,并试图思考为什么以及何时执行哪个。
我目前正在学习 Rust 并希望用它来开发 GUI基于 GTK+ 的应用程序。我的问题与注册回调有关在这些回调中响应 GTK 事件/信号和变异状态。我有一个有效但不优雅的解决方案,所以我想问一下是否有
我在回调函数中传递参数时遇到问题。我使用 redux-form,当我更改 SkinList 中的选择时,它会触发 onChange 回调 - activeSkinChange 方法 在activeSk
我有 8 个相互依赖的回调。我的想法是要有一个更具可读性的过程,但我不明白如何处理这个问题。 我的回调 hell 的一个例子是: return new Promise(function (resolv
因此,我的函数接受一个值和任意数量的回调作为参数(我应该使用扩散操作符吗?)该函数应该返回通过所有给定回调传递该值的最终结果。。我返回的“CB2(Res1)”不是一个函数。如何将第一个回调的结果传递给
在谈到 future 和回调时,documentation说是 The Vert.x core APIs are based on callbacks to notify of asynchronou
我开始觉得自己很蠢。我正在关注 Facebook-Connect 演示“The Run Around”。 当我导航到 http://www.[mysite].com/testing/register_
我是一名优秀的程序员,十分优秀!