这个是按钮的HTML代码<asp:ImageButton ID="EditRow" runat="server" ImageUrl="~/img/edit.bmp" OnCommand = "Edit_Click"  />&nbsp;
                    </ItemTemplate>
在对应CS文件中存在Edit_Click 的方法如下:        protected void Edit_Click(object sender, CommandEventArgs e)
        {
            ///string arrgument = e.CommandArgument.ToString();
            Response.Redirect("WebForm2.aspx");
        }
本来预想的是点击gridview中按钮,然后跳转页面到WebForm2..可是一直都报错,如下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.  
网上得解说是什么安全性问题。 - -||  不过不知道怎么解决。。还请不吝赐教

解决方案 »

  1.   

    根据错误提示If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. 
    楼主用如下方法试试:
      protected void Edit_Click(object sender, CommandEventArgs e)
            {
                string url = "WebForm2.aspx";
                this.Page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>window.location=\"" + url + "\"</script>");
            }
      

  2.   

    不应该触发这个事件吧!那个按钮是在gridview中吗?把完整代码放上来啊!
      

  3.   

    楼主所贴的代码肯定没错!!
    错是其他地方引起的!!
    特别是进入Edit,会引起多方错误!!
      

  4.   

    如果使用跳转功能
    直接使用模板列<a href
    或Hyperlink
    检查编码,添加EnableEventValidation="true" 
      

  5.   

    gridview_command事件里面写吧,不是直接写在onclick里面哦
      

  6.   

    <asp:ImageButton ID="EditRow" runat="server" ImageUrl="~/img/edit.bmp" OnClick = "Edit_Click"  />&nbsp;
                        </ItemTemplate>
     protected void Edit_Click(object sender, CommandEventArgs e)
            {
                ///string arrgument = e.CommandArgument.ToString();
                Response.Redirect("~/WebForm2.aspx");//注意路径
            }